cron problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dannyd
Forum Commoner
Posts: 56
Joined: Wed Jan 23, 2008 11:31 am

cron problem

Post by dannyd »

My cron works on the command line but not as a crontab.

How can I get it working as a crontab ?
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Re: cron problem

Post by Mightywayne »

Erm, which OS are you using? For example in Plesk, you just go to the cron tab and deselect the command line option.
dannyd
Forum Commoner
Posts: 56
Joined: Wed Jan 23, 2008 11:31 am

Re: cron problem

Post by dannyd »

Fedora Core 4.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: cron problem

Post by Zoxive »

How are you executing it in command line & crontab?

Are you using shebang? Or Full path to php?
dannyd
Forum Commoner
Posts: 56
Joined: Wed Jan 23, 2008 11:31 am

Re: cron problem

Post by dannyd »

Im using this at the top of the script:

#!/usr/local/bin/php -q


And this line to execute on the command line:

php -a ./logs
dannyd
Forum Commoner
Posts: 56
Joined: Wed Jan 23, 2008 11:31 am

Re: cron problem

Post by dannyd »

theres other cron scripts working before I started fine.

Not sure exactly why mine only works on the command line and not using crontab.
dannyd
Forum Commoner
Posts: 56
Joined: Wed Jan 23, 2008 11:31 am

Re: cron problem

Post by dannyd »

when I run the cron on the command line it works fine .. but it also says Interactive mode enabled when I run it:

[root@web1 cron]# php -a ./logs
Interactive mode enabled

Processing the following files:<BR>080203log.txt


It doesnt work as a crontab. My crontab entry is fine to run at 10:20am.

20 10 * * * /usr/local/cron/logs
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Re: cron problem

Post by Mightywayne »

Your host will more than likely know how to help you.
dannyd
Forum Commoner
Posts: 56
Joined: Wed Jan 23, 2008 11:31 am

Re: cron problem

Post by dannyd »

I dont have a host. Im on my own managed server.
dannyd
Forum Commoner
Posts: 56
Joined: Wed Jan 23, 2008 11:31 am

Re: cron problem

Post by dannyd »

Mar 6 11:57:01 intranet crond[2286]: (tmp.XXXXGHJVjz) ORPHAN (no passwd entry)
Mar 6 11:57:01 intranet crond[2286]: (root) RELOAD (cron/root)
Mar 6 11:57:01 intranet crond[2286]: (tmp.XXXXFqiL6E) ORPHAN (no passwd entry)

Anyone know what this means.

This is the error I get in my cron log file. I suspect its not running the file as root which it is supposed to. How can I set the user to run the cron job ?

Let me know if im wrong.
dannyd
Forum Commoner
Posts: 56
Joined: Wed Jan 23, 2008 11:31 am

Re: cron problem

Post by dannyd »

Figured it out:

1. 20 10 * * * /usr/local/bin/php -a /usr/local/cron/logs
2. restart crond
Post Reply