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

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
xlulux
n00b
n00b


Joined: 20 Aug 2004
Posts: 63

PostPosted: Sun Oct 03, 2004 11:18 pm    Post subject: crontab tutorial Reply with quote

Hi

This is kind of a work in progress but explains the basics and gives an example on how to do it, replies would be appreciated



####how to use/make cron jobs####

cron jobs are jobs that are run automatically when scheduled by a special application called crontab. I'm not sure if theres a port for windows, but there is the 'at' command for windows xp so look into that for further info

1 using crontab

crontab has some pretty simple syntax that goes like this
-u user
-l list crontab
-e edit crontab entries
-h show you the help
you can find more indepth stuff in the manual pages (man crontab)

at first you should try doing a
# crontab -l -u yourusername
~~i needed to be root to do this, you might have somehting diffrent but root works
then you can see what entries are there, if you see something like

tux ~ # crontab -u vicente -l
no crontab for vicente

then you have to make a crontab for your account, first you run the edit command and it will find that you dont have a crontab and make one automatically

tux ~ # crontab -e
no crontab for root - using an empty one
crontab: installing new crontab

now you can add the cron jobs you want, this is the syntax for them

Minute - Minutes after the hour (0-59).
Hour - 24-hour format (0-23).
Day - Day of the month (1-31).
Month - Month of the year (1-12).
Weekday - Day of sdthe week. (0-6; the 0 refers to Sunday).

using an astrisks (*) means every instance of this period of time

so this is an example of a cron job here

30 23 * * * /home/vicente/runscript.sh

this a script that runs at 1130 pm daily .

i think you can get the basics from this

~~ it might be better for you to use absolute paths instead of just typing

rm /path/file
you should type /usr/bin/rm /path/file
because this wont give any leeway for the program to be exploited later on.


hope you liked my tutorial, send comments and questions to vicente_louvet@yahoo.com
Back to top
View user's profile Send private message
jftuga
Tux's lil' helper
Tux's lil' helper


Joined: 21 Jan 2004
Posts: 139
Location: Athens, GA

PostPosted: Mon Oct 04, 2004 12:41 am    Post subject: Reply with quote

Nice tutorial! You should consider reposting it to the Documentation, Tips & Tricks forum.

-John
Back to top
View user's profile Send private message
Bigbeanpole
n00b
n00b


Joined: 24 Apr 2003
Posts: 12

PostPosted: Mon Dec 13, 2004 10:49 pm    Post subject: What about / ? Reply with quote

When using cron jobs, what about when you */4 ... would that do it for every 4th iteration of the time period?

So 0 0 */7 * * would be every 7th day?

To get a weekly cron setup, would the entry

Code:
0 0 0 * 2 commands

be sufficient to have a command run every Tuesday at midnight?
Back to top
View user's profile Send private message
ian!
Bodhisattva
Bodhisattva


Joined: 25 Feb 2003
Posts: 3829
Location: Essen, Germany

PostPosted: Tue Dec 14, 2004 7:47 am    Post subject: Reply with quote

Moved from 'Portage & Programming'.
_________________
"To have a successful open source project, you need to be at least somewhat successful at getting along with people." -- Daniel Robbins
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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