LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   cron job? (https://www.linuxquestions.org/questions/linux-software-2/cron-job-49984/)

luap 03-15-2003 01:29 PM

cron job?
 
hello,
once i get my firewall/nat issues resolved, i was thinking
of trying to automate control of my ppp0 nternet connection. currently i start/stop the dsl modem with
short scripts(commands?) anyway, would cron work if i set it up like this:

#turn off modem at 9:15 pm sunday thru thursday, school nights
15 21 * * 0-4 /etc/rc.d/init.d/speedtouch stop
#turn on modem at 9:20 pm sunday thru thursday, i dont go to school
20 21 * * 0-4 /etc/rc.d/init.d/speedtouch start
#turn off modem at 1:30am friday and saturday, let em frag!
30 01 * * 5,6 /etc/rc.d/init.d/speedtouch stop

cron folks, does the syntax look right?(there is a space before the "/etc....")
does 0 = sunday for sure? should i use "sun,mon,tue,wed" instead?
if i run this and it doesnt work,will damage system?
i dont run my machine perpetually- dumb question, will cron jobs
resync to time and run as scheduled?

thanks for any help, tips, comments...

ernie 03-16-2003 12:16 AM

First, I don't know if I would want to start / stop my Internet connection with a cron job, because I may be doing something important, and losing my connection at a scheduled time could cause me to lose my work.

What I do to keep from losing track of time when at my computer is as follows:

I have installed a text to speech software called festival. festival can be downloaded from the University of Edinburgh. The URL is:

http://www.cstr.ed.ac.uk/projects/festival/

You can echo text to festival as:

echo "This is the text string I want to hear" | festival --tts

which pipes the output of the echo command to festival, and the --tts tells festival to treat this input as text-to-speach, and output it to the sound system

I have also created a few scripts which use festival.

One reports the system time each quarter hour using my sound system.

The other is a wrapper for festival so I can create scheduled reminders in cron as:

spkup "Time to get ready for work!"

I set the job to run 30 minutes before I must be at work for 5 consecutive minutes on all 5 days I work. It can be irritating, but I am never late for work.

I also use cron to run fetchmail each quarter hour to retrieve any email. This way, I do not have to run fetchmail as a daemon. I like running services only when I am using them.

If you open a terminal window, and enter:

man 5 cron

You will get the following information with more detail:

The fields in a cron command are as follows:

minute [0-59]<SP>hour [0-23]<SP>day of month [1-31]<SP>month [1-12]{or month name(s)}<SP>day of week [0-7] {0 or 7 = sun, or use names}

Any entry may be a <*> which means first-last

ranges may be used in the form 8-11 which is equal to 8 and 9 and 10 and 11

Lists may be used in the form 1,2,5,9 which is equal to 1 and 2 and 5 and 9

Lists of ranges are permitted as 0-4,8-12 which is equal to 0 and 1 and 2 and 3 and 4 and 8 and 9 and 10 and 11 and 12

ranges may be stepped through as 0-6/2 which is equal to 0 and 2 and 4 and 6

You may step through an entire range with */2 - for example, if you wanted to do something each 2 hours, you can use */2 in the hour field

Hope this helps,

luap 03-16-2003 08:48 AM

hello ernie, thanks for the info. the festival software may prove useful, but not for the task i have in mind.


All times are GMT -5. The time now is 11:52 PM.