Strawberry
Strawberry

Reputation: 67868

Crontab is working but PHP script isn't working as planned?

I'm not sure how can I debug this, I set the crontab and walked away earlier and came back with no results. Just now, I ended up using this thread: Using CronTab to run php scripts and have it set to run every minute. My PHP script isn't running. I tried wget and php. It works when I visit it in the browser, but not when crontab is running it.

Update:

May 16 10:39:01 strawberry /USR/SBIN/CRON[12283]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -print0 | xargs -n 200 -r -0 rm)

So it fired off but I'm still not getting expected results. However, it works when I go to the website url. I'm using this in my crobtab: https://stackoverflow.com/a/5134125/170365

* * * * * wget http://mysite.com/myscript >/dev/null 2>&1

I also tried running it as www-data and root: How to set a crontab using php?

Upvotes: 0

Views: 211

Answers (1)

Riking
Riking

Reputation: 2480

You can examine the cron logfile by creating an email account for root on the machine. If this is too much for you, you can try the following in your crontab:

# m h dom month dow command
0,15,30,45 * * * * touch /home/strawberry/crontest

(using /15 might work too but i haven't tested that)

Wait for the 15-minute mark, and check if the crontest file has been created. This will tell you if it's running at all.

If you need the output, do something like this:

# m h dom month dow command
(the time parameters you want) /path/to/command args args args > /blah/blah/cronlogfile 2>&1

Also, try putting '/1' for the minute mark, that should make it go every minute

Upvotes: 1

Related Questions