Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Cron in Gentoo
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
lurid
Guru
Guru


Joined: 12 Mar 2003
Posts: 595
Location: Florida

PostPosted: Sat Sep 06, 2003 9:02 am    Post subject: Cron in Gentoo Reply with quote

I need some Gentoo specific help with setting up cron jobs. I understand how cron works, but I don't understand how its organized in Gentoo. It apears that /etc/crontab is the "master" cron file which then runs entries in the /etc/cron.* dirs. My problem is that I want certain programs to update every hour, and others to update every three hours. In Gentoos setup it looks as though you're stuck running whatever is in /etc/cron.daily at the same time.

Is there a way to alter this some how? I tried adding a new entry to /etc/crontab specifically for the program I want to run every three hours, rather than sticking it in /etc/cron.daily, but it doesn't seem to work.

Any suggestions?

EDIT: Erm, I have no idea how this got in the Portage section. Please move it. Thanks. :oops:
_________________
Go find a cheerleader and saw her legs off. - Nny
Back to top
View user's profile Send private message
skunk
l33t
l33t


Joined: 28 May 2003
Posts: 646
Location: granada, spain

PostPosted: Sat Sep 06, 2003 11:22 am    Post subject: Reply with quote

1. don't edit /etc/crontab manually!
2. read man 5 crontab
3. run crontab -e and put your jobs there ex:
Code:

0 0-23/3 * * * /path/job.sh # run job.sh every 3 hours
Back to top
View user's profile Send private message
lurid
Guru
Guru


Joined: 12 Mar 2003
Posts: 595
Location: Florida

PostPosted: Sat Sep 06, 2003 11:28 am    Post subject: Reply with quote

Yeah, originally I was going to do the 'crontab -e' but looking at /etc/crontab it said

Quote:
remember to give cron a sighup when updating this file


So I assumed it could be edited. :?
_________________
Go find a cheerleader and saw her legs off. - Nny
Back to top
View user's profile Send private message
skunk
l33t
l33t


Joined: 28 May 2003
Posts: 646
Location: granada, spain

PostPosted: Sat Sep 06, 2003 11:54 am    Post subject: Reply with quote

lurid wrote:
So I assumed it could be edited. :?

yes, but what's the point then? i don't see any issue for running a job every 3 hours...
maybe i misunderstood your problem?
Back to top
View user's profile Send private message
lurid
Guru
Guru


Joined: 12 Mar 2003
Posts: 595
Location: Florida

PostPosted: Sat Sep 06, 2003 1:24 pm    Post subject: Reply with quote

I just ment that I assumed I could edit it. No biggie, just a mistake in logic on my part. Still not working, though. I used crontab -e as root and entered these two lines

Code:
37 0,3,6,9,12,15,18,21 * * * /path/to/file
*/15 * * * * /path/to/file


The first one should run on 12:37am, 3:37am, 6:37am and so on. The second should run every 15 minutes. Is my formatting correct? From what I've read it would appear so. Cron is running and I did use the crontab -e command to set them. The question of the hour is now: Why isn't it working? Obviously I can only check the first one on specific hours, but the second should be easily noticed.

(obviously '/path/to/file' is correct in the real crontab, just thought I'd mention that. ;)
_________________
Go find a cheerleader and saw her legs off. - Nny
Back to top
View user's profile Send private message
bsnipes
n00b
n00b


Joined: 30 May 2002
Posts: 37

PostPosted: Sun Sep 07, 2003 2:29 am    Post subject: Reply with quote

On one of my systems the cron daemon wasn't looking at /etc/crontab but at a different crontab so that when I edited with 'crontab -e' as root my changes never occured. Check to see if there is another crontab file on your system and if so symlink it to the /etc/crontab file.

Brian
Back to top
View user's profile Send private message
lurid
Guru
Guru


Joined: 12 Mar 2003
Posts: 595
Location: Florida

PostPosted: Sun Sep 07, 2003 12:52 pm    Post subject: Reply with quote

Ok, there is an /etc/crontab which looks like this:

Code:
# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
# for vixie cron
# remember to give cron a sighup when updating this file
#
# $Header: /home/cvsroot/gentoo-x86/sys-apps/vcron/files/crontab,v 1.2 2002/04/27 21:46:45 bangert Exp $
#
#
*/15 * * * *    root    test -x /usr/sbin/run-crons && /usr/sbin/run-crons
0 *  * * *      root    rm -f /var/spool/cron/lastrun/cron.hourly
0 6  * * *      root    rm -f /var/spool/cron/lastrun/cron.daily
0 0  * * 6      root    rm -f /var/spool/cron/lastrun/cron.weekly
0 0  1 * *      root    rm -f /var/spool/cron/lastrun/cron.monthly


When using crontab -e, it doesn't touch this file, it instead creates /var/spool/cron/crontabs with a text file called root which has my jobs in it.

What looks like its doing is cron is running /etc/crontab which tests to see if /usr/sbin/run-crons is there and executable (test -x /usr/sbin/run-crons) and then runs it. Evidently its the run-crons program that is what is actually executing cron jobs. The remainder of the the /etc/crontab file just cleans up. So it would seem that 'run-crons' doesn't see roots cronfile. What strange is that if I edit /etc/crontab manually, nothing happens either, even though its obviously being looked at by cron and things are being executed.

This entire setup makes no sense to me. Why have these daily/hourly/weekly/etc dirs? While it might be easy to just stick a shell script into a dir and have it run, everything in it will run at the same time. So what happens when I have apps I want to run at different times, or specific times? This set up seems really inflexable. Even if I took the above advice and linked /var/spool/cron/crontabs/root to /etc/crontab, that would render anything I _did_ have in the hourly/daily/etc dirs useless.

Am I totally confused as to how cron works, or is this setup just crap? :x
_________________
Go find a cheerleader and saw her legs off. - Nny
Back to top
View user's profile Send private message
bsnipes
n00b
n00b


Joined: 30 May 2002
Posts: 37

PostPosted: Sun Sep 07, 2003 4:57 pm    Post subject: Reply with quote

If I recall correctly what I did was to symlink the one in /var to the /etc/crontab file. Then when I 'crontab -e' I added my entries to the bottom and all ran well. Maybe not the original way it was intended but it worked.

Brian
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum