LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 11-21-2009, 01:16 AM   #1
Corrado
Member
 
Registered: Aug 2004
Location: Washington
Distribution: RHEL 5.0
Posts: 126

Rep: Reputation: 16
Creating cron job


I have to install many cron jobs on my machines. I have a script which will copy /var/spool/cron/root onto the machines. Once the file is placed on the machine, I then have crond restarted.

When I do "crontab -l" I do see the jobs listed but, I noticed that they are not started at anytime. I tried "crond reload" and that doesn't work.


After the file is in place, what do I have to reload? I must be missing what crontab does automatically during an edit.

Chris
 
Old 11-21-2009, 01:34 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 38,406

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
You shouldn't have to restart anything, cron will pick up the new file automatically. I wouldn't personally recommend managing jobs with a root crontab, instead I use /etc/crontab as the system wide table. How are you checking these haven't loaded? what does /var/log/cron say?
 
Old 11-21-2009, 02:15 AM   #3
Corrado
Member
 
Registered: Aug 2004
Location: Washington
Distribution: RHEL 5.0
Posts: 126

Original Poster
Rep: Reputation: 16
/var/log/cron has no mention of any job ever being started. To verify if cron is starting the jobs.

Quote:
*\1 * * * * touch /tmp/new
The file is never created in tmp. "cron -l" shows the jobs as being loaded.

When I being up "crontab -e" and save it. The job works.

Chris
 
Old 11-21-2009, 02:37 AM   #4
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 115Reputation: 115
Quote:
Originally Posted by Corrado View Post
/var/log/cron has no mention of any job ever being started. To verify if cron is starting the jobs.



The file is never created in tmp. "cron -l" shows the jobs as being loaded.

When I being up "crontab -e" and save it. The job works.

Chris
couple of things wrong with your example.
you want this cron to run every minute right??

then simply this is enough

Code:
* * * * *

secondly, ensure you use full path to the command if using individual user crontabs

Code:
* * * * * /usr/bin/touch /tmp/new
 
Old 11-21-2009, 02:38 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 38,406

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
the format is wrong, *\1 should be */1, but is just the same as * by itself. again, using /etc/crontab would be preferable. I guess crond checks that file automatically, as opposed to the per-user crontab files.
 
Old 11-21-2009, 02:26 PM   #6
Corrado
Member
 
Registered: Aug 2004
Location: Washington
Distribution: RHEL 5.0
Posts: 126

Original Poster
Rep: Reputation: 16
The every minute cron job works fine when the entry is added in "crontab -e" (sorry, about the typo)

The same job does not work when the file ../cron/root is copied to the right location.

Anyone know why this does not load? Or how to get it located?

Chris
 
Old 11-21-2009, 02:33 PM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 38,406

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
becuase that's what the crontab command does, installs the file.
 
Old 11-22-2009, 05:00 AM   #8
Corrado
Member
 
Registered: Aug 2004
Location: Washington
Distribution: RHEL 5.0
Posts: 126

Original Poster
Rep: Reputation: 16
How do I load the file manually without crontab?
 
Old 11-22-2009, 11:12 AM   #9
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 115Reputation: 115
Quote:
Originally Posted by Corrado View Post
How do I load the file manually without crontab?
use your favorite editor with
Code:
crontab -e

or

crontab <file>


file being the cron file just created

Last edited by centosboy; 11-22-2009 at 11:58 AM.
 
Old 11-23-2009, 01:28 PM   #10
Corrado
Member
 
Registered: Aug 2004
Location: Washington
Distribution: RHEL 5.0
Posts: 126

Original Poster
Rep: Reputation: 16
Centosboy, that did the trick.

Quote:
crontab /var/spool/cron/root
It reloaded everything. Something so obvious. Kicking myself for not trying it. Thank you.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
linux cron job duplicate job question cpthk Linux - Newbie 4 09-11-2009 09:52 PM
Cron job script creating corrupt archive roach7711x Linux - Server 2 04-08-2009 05:01 AM
Creating a cron job to email me a txt file/format? NewShockerGuy Linux - General 7 05-16-2008 10:23 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 09:16 AM
newbie needing help creating a cron job Lleb_KCir Linux - Software 5 12-13-2004 04:58 PM


All times are GMT -5. The time now is 10:42 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration