LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Centos 6.2 Cron Jobs (https://www.linuxquestions.org/questions/linux-server-73/centos-6-2-cron-jobs-935473/)

jeffreydavisjr 03-20-2012 09:19 AM

Centos 6.2 Cron Jobs
 
I am trying to set php scripts to run via cron jobs in the middle of the night. I am editing the dailyjobs file in /etc/cron.d. For testing purposes I just wanted to run the job every minute... So I edited the file to look like this:

Code:

* * * * * php /path/to/script.php
I have installed cronie-noanacron and remove cronie-anacron.

Thanks.

acid_kewpie 03-20-2012 09:38 AM

ok. good for you. was there a question?

TenTenths 03-20-2012 10:11 AM

You may have to define the whole path to php in your cron job.

jeffreydavisjr 03-20-2012 10:22 AM

Quote:

Originally Posted by acid_kewpie (Post 4631600)
ok. good for you. was there a question?

Yes, the script isn't running... when I run the command:

Code:

php /path/to/script.php
manually it runs fine. But cron isn't automatically doing it for me.

My dailyjobs files looks like this.
Code:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
02 4 * * * root [ ! -f /etc/cron.hourly/0anacron ] && run-parts /etc/cron.daily
22 4 * * 0 root [ ! -f /etc/cron.hourly/0anacron ] && run-parts /etc/cron.weekly
42 4 1 * * root [ ! -f /etc/cron.hourly/0anacron ] && run-parts /etc/cron.month$
* * * * * php /var/www/interactivestorage.com/cron/jobs/check_subscription.php


acid_kewpie 03-20-2012 10:32 AM

right so clearly you've got a different format to the other lines. you've no user account listed there, where the other lines all run as root (this is a difference in the /etc/crontab file compared to other user crontabs where this field does not exist), and also as above you should use the full path to the php binary for good measure.

jeffreydavisjr 03-20-2012 10:35 AM

Wait, so should I be using the /etc/crontab file or the /etc/cron.d/dailyjobs file?

acid_kewpie 03-20-2012 10:54 AM

personally I've never heard of "dailyjobs" before, but that file is exactly what should be in /etc/crontab. Google says this is new in el6 so something I should read up on... Eitehr way, correct that line and go from there.

jeffreydavisjr 03-20-2012 12:22 PM

Problem solved. I simply did it through webmin. I did yum install crontab and it installed that package and 2 dependent packages. I then went into Webmin and setup the job to run and it completed fine.

acid_kewpie 03-20-2012 01:01 PM

ewww webmin is nasty. kill it with fire.


All times are GMT -5. The time now is 09:36 AM.