LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-15-2001, 07:23 AM   #1
yogotie
Member
 
Registered: Mar 2001
Distribution: Slackware 9.0
Posts: 32

Rep: Reputation: 15

I want to start a certain program at a certain time of the day to run a peticular task. Such as being an alarm clock to wake me up from my great slumber.

Does any one know how I can do this. I am guessing there is an app if that is so which one is the best.
 
Old 05-15-2001, 07:26 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
That I believe you can use with Cron.
 
Old 05-16-2001, 04:42 AM   #3
yogotie
Member
 
Registered: Mar 2001
Distribution: Slackware 9.0
Posts: 32

Original Poster
Rep: Reputation: 15
hmmm...so how do you use cron?
can you give me an example of how setup cron?

I looked at some of the mans and stuff but they did not say much about how to format the cron files to make something start at a sertain time.
 
Old 05-17-2001, 06:35 PM   #4
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 47
Talking

you can edit your crontab (the Cron file that controls execution for a specific user) by using the 'contab -e' command, this will fire up vi (or something like it) so you can edit the file. If you (like some of my friends) find Vi evil you can edit the file directly, which is probably in /var/spool/cron/crontabs/<username>

Heres a bit of my crontab for root on my server:

==========================================================
0-59/5 * * * * /sbin/rmmod -a
0-59/15 * * * * /sbin/ddupcron.sh jharris.homeip.net > /dev/null 2>&1
0 0,6,12,18 * * * /sbin/ntpdate.sh
59 * * * * /usr/local/bin/webalizer > /dev/null 2>&1
==========================================================

The first line runs 'rmmod -a' every 5 minutes, the second runs 'ddupcron.sh' every 15 minutes - note the redirection of stdout & stderr. Any output produced by a command that is executed by Cron is emailed to the user, this would mean that every 15mins root would get an email!

The third command runs 'ntpdate.sh' on minute zero of hours 0, 6, 12, and 18. Seeing a pattern yet? The star means all.

So its goes something like

mins hours day-of-month month weekday command

so to execute something every 30 mins every 16th day of every month (why?!?) you would use

30 * 16 * * myCommand

The weekday entry changes per system, on BSD its normally 1-7 where 1 is Monday, on SysV is normally 0-6 where 0 is Sunday. As Linux comes from both I dunno which is which. Nothing that a man page couldn't sort out. Here are the other examples from 'man crontab'


# MIN HOUR DAY MONTH DAYOFWEEK COMMAND
# at 6:10 a.m. every day
10 6 * * * date

# every two hours at the top of the hour
0 */2 * * * date

# every two hours from 11p.m. to 7a.m., and at 8a.m.
0 23-7/2,8 * * * date

# at 11:00 a.m. on the 4th and on every mon, tue, wed
0 11 4 * mon-wed date

# 4:00 a.m. on january 1st
0 4 1 jan * date

# once an hour, all output appended to log file
0 4 1 jan * date >>/var/log/messages 2>&1

HTH

Jamie...
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DEbian autostart?? Hargibi Linux - Software 2 04-19-2005 03:09 AM
Apache Autostart gsoft Linux - Software 3 04-15-2005 08:23 PM
autostart noobtesting Mandriva 3 07-04-2004 11:45 AM
Autostart wampfler Fedora 2 01-01-2004 02:18 PM
Autostart Haiyadragon Mandriva 4 12-26-2003 06:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:31 PM.

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