views:

560

answers:

2

at title how can i shell script in mac os x at a certain time,i know it is something related to cron but i cannot figure it out how to achieved can somebody provide some code

A: 

Check this tutorial out.

Can you tell us where are you stuck at?

amartin
+1  A: 

crontabs are files read by the cron daemon. They tell it to perform actions (such as running a shell script) at various times. More info here.

http://www.macdevcenter.com/pub/a/mac/2001/12/14/terminal_one.html

In a Linux terminal I type:

crontab -e

An example would be

30  4 * * 6 root sh /etc/weekly  2>&1 | tee /var$ …

for a weekly run at 4:30

.---------------- minute (0 - 59) 
|  .------------- hour (0 - 23)
|  |  .---------- day of month (1 - 31)
|  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ... 
|  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7)  OR sun,mon,tue,wed,thu,fri,sat 
|  |  |  |  |
*  *  *  *  *  command to be executed

So every day, running foo at 2:00 would be ...

0  2  *  *  *  foo

The above tutorial contains OSX instructions for editing your crontab file!

good luck

See also: http://developer.apple.com/documentation/Darwin/Reference/Manpages/man5/crontab.5.html The OSX crontab man-page

and

http://en.wikipedia.org/wiki/Cron

Aiden Bell