LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-20-2012, 10:19 AM   #1
jeffreydavisjr
LQ Newbie
 
Registered: Aug 2006
Posts: 13

Rep: Reputation: 1
Question 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.
 
Old 03-20-2012, 10:38 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
ok. good for you. was there a question?
 
Old 03-20-2012, 11:11 AM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,123

Rep: Reputation: 1328Reputation: 1328Reputation: 1328Reputation: 1328Reputation: 1328Reputation: 1328Reputation: 1328Reputation: 1328Reputation: 1328Reputation: 1328
You may have to define the whole path to php in your cron job.
 
Old 03-20-2012, 11:22 AM   #4
jeffreydavisjr
LQ Newbie
 
Registered: Aug 2006
Posts: 13

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by acid_kewpie View Post
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
 
Old 03-20-2012, 11:32 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
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.
 
Old 03-20-2012, 11:35 AM   #6
jeffreydavisjr
LQ Newbie
 
Registered: Aug 2006
Posts: 13

Original Poster
Rep: Reputation: 1
Wait, so should I be using the /etc/crontab file or the /etc/cron.d/dailyjobs file?
 
Old 03-20-2012, 11:54 AM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
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.

Last edited by acid_kewpie; 03-20-2012 at 11:58 AM.
 
Old 03-20-2012, 01:22 PM   #8
jeffreydavisjr
LQ Newbie
 
Registered: Aug 2006
Posts: 13

Original Poster
Rep: Reputation: 1
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.
 
Old 03-20-2012, 02:01 PM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
ewww webmin is nasty. kill it with fire.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Centos 6 don't run my cron jobs ASTRAPI Linux - Server 2 01-15-2012 02:42 AM
cron hourly, daily, cron.d jobs don't execute eggsmartha Linux - General 3 09-17-2007 07:37 PM
Cron Jobs christo512 Linux - Software 1 02-09-2006 10:19 AM
Cron Jobs XaViaR Linux - General 1 06-23-2005 07:57 PM
cron jobs working2hard Linux - Software 0 07-28-2004 06:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration