LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 10-06-2005, 07:54 AM   #1
tomasv
LQ Newbie
 
Registered: Oct 2005
Posts: 1

Rep: Reputation: 0
Cron question


Hi,
I hope this is the right forum for this question.

I have a question regarding cron. Is it possible to get your Crontab file to include anoter crontab file?

Say for example that I have a website that have 20 scripts running at different times using Cron. I would like to setup a file called sitecron.txt like this:

0 1 * * * script1.hs
0 2 * * * script2.hs
0 3 * * * script3.hs
etc.

And then in my main cron file (the one I get when typing crontab -e) I would like to write something like this:

0 1 * * * normalcrontabscrip
<include sitecron.txt>

Is it possible to do an include like that in any way? I know I can just type everything in the main file but doing it like this would making things alot easier to maintain.

Thanks in advance!

Tomas
 
Old 10-06-2005, 09:20 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
I don't see that this would be easier to maintain.

I suspect what you're saying is you have a lot you'd like to put in cron and want to do a simple edit session of a file rather than relying on crontab -e. If that's the case you can always just edit the cron file itself. (In fact I did this all the time before I found out about crontab -e.)

The cron files are in /var/spool/cron/crontabs. There should be a file with the name of the user that has cron entries. For most people the only one will be /var/spool/cron/crontabs/root.

I'd recommend saving the file before editing. Usually I do something like:
"cp -p root root.YYYYMMDD where YYYYMMDD" is current year, month and day.

After doing the edit just do "crontab -l" to verify cron sees the changes you made.

Of course you could just do your separate file and cat it into the end of the root cron file noted above:

"cat mycronfile >>/var/spool/cron/crontabs/root" to append to what is there

"cat mycronfile >/var/spool/cron/crontabs/root" to overwrite what is there.

Having said all that I'd say for most uses crontab -e is the way to go.

Last edited by MensaWater; 10-06-2005 at 09:23 AM.
 
  


Reply



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
cron question dennis_89 Linux - General 2 07-05-2004 02:09 PM
CRON question. Hal Linux - Newbie 2 12-20-2003 05:38 AM
cron question paperdiesel Linux - Newbie 2 10-29-2003 03:28 PM
Cron question. Thetargos Linux - Software 1 07-19-2003 06:19 AM
cron question Jase Linux - Networking 1 01-26-2002 11:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:45 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