0

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?

Community
  • 1
  • 1
Strawberry
  • 58,930
  • 53
  • 138
  • 190

1 Answers1

1

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

Riking
  • 2,149
  • 19
  • 33
  • I'm actually having it run everyone minute `1 * * * * wget http://mysite.com/myscript >/dev/null 2>&1` Just to see if it works, and I'm not getting the expected results. – Strawberry May 16 '12 at 17:27
  • That is not every minute. That is the first minute of every hour. ...Well, I guess that may have been your problem :) – Riking May 16 '12 at 17:29
  • You're right. That was my mistake, but I just checked the log and it fired off, but it didn't work as I was expecting. – Strawberry May 16 '12 at 17:33