Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
bash programming: cron scheduling
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
Deathwing00
Bodhisattva
Bodhisattva


Joined: 13 Jun 2003
Posts: 4087
Location: Dresden, Germany

PostPosted: Sun Nov 02, 2003 9:33 pm    Post subject: bash programming: cron scheduling Reply with quote

FIRST
All right, I would like to program cron so a program runs every 5 minutes in my system like:

Code:
echo */5 * * * 6 root  /root/scheduled.sh >> /etc/crontab


But I want it to run from let's say 7 AM to 9 PM...

This means that it'll run every 5 minutes starting at 7 AM and doing it no longer after 9 PM. It should start over again the next day...

---------------------------

SECOND
Is there a file to only-allow a certain group to be able to schedule using cron? This is because of the need that only system administration group users should be able to use cron to schedule jobs, but the group must be different than root and so. The other groups with their respective users should be able schedule only with at, this is, non-periodical jobs.

TIA
Back to top
View user's profile Send private message
Stu_28
Tux's lil' helper
Tux's lil' helper


Joined: 12 Jun 2003
Posts: 129

PostPosted: Mon Nov 03, 2003 12:03 am    Post subject: Reply with quote

If you are using dcron, something like this should suffice:

Code:


7-21/5 * * * *  /root/scheduled.sh



Otherwise, if the cron you have doesn't have this ability, you could add this to the beginning of the shell script:

Code:


HOUR=`date +"%k"`
if (( $HOUR < 7 )) || (( $HOUR > 20 )) ; then
  exit 0
fi



Of course, this won't run at 21:00, for that you'd have to look at the minutes as well.

Also, there is a cron group and if you aren't in it you can't use cron. However, if you want anything more flexible than that you should look into Access Control Lists.
Back to top
View user's profile Send private message
Deathwing00
Bodhisattva
Bodhisattva


Joined: 13 Jun 2003
Posts: 4087
Location: Dresden, Germany

PostPosted: Mon Nov 03, 2003 10:42 am    Post subject: Reply with quote

Thanks, that'll do for me...

the cron I use is the most simple one, provided in LFS (Linux From Scratch)

Gotta say LFS is a fake distribution... as there are no packages to be distributed.
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