LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-10-2005, 07:48 PM   #1
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Rep: Reputation: 47
Scheduling scripts


I have a radio script that I run at 5:00 that streams radio in the morning while I get around. I'd like to automate this to run at 5:00 AM M-F. Could I use cron for this-if so, how?
 
Old 11-10-2005, 08:38 PM   #2
GrueMaster
Member
 
Registered: Aug 2005
Location: Oregon
Distribution: Kubuntu.
Posts: 848

Rep: Reputation: 30
Create a crontab file like so (minus the # comments):
crontab -e # This will open your default text editor. Exapmle will assume vi
i #enter insert mode
0 5 * * 1-5 <cmdline> # where <cmdline> is the full path to the command to execute followed by what ever parameters it requires
<esc>:wq # exit edit mode, save and quit

This will save your crontab file. To view it, type "crontab -l". You can add as many cmdlines as you want.

A little explanation of the crontab file format (from the man 5 crontab pages):




Quote:
The time and date fields are:

field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)
Also, please note that all output of the executed command will appear in your email unless you pipe them to somewhere else. Ex:
0 5 * * 1-5 /usr/bin/play someaudio.wav >~/play.log 2>&1 # will play an audio file at 5:00am Monday through Friday, logging all output to a log file.

* * * * * /usr/games/fortune # send me an email every hour with my fortune

Hope this helps.
 
Old 11-10-2005, 09:12 PM   #3
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
Great! Got it working now-I'll be waking up to my Streaming Clock Radio now. Thanks for the help!

I'm not too familiar with how to use vi, so I made a one line file called cron with the parameters you mentioned in pico. Then I moved it into the cron log using:

crontab cron

I then listed the cron job with crontab -l

crontab --help gives options
 
Old 11-10-2005, 09:56 PM   #4
GrueMaster
Member
 
Registered: Aug 2005
Location: Oregon
Distribution: Kubuntu.
Posts: 848

Rep: Reputation: 30
Cool.

As an extra bit of info, you can change the default editor to the editor of your choice by setting the edit variable.

Ex:

#For bash, add to ~/.bash_profile
set EDITOR=<path to pico>
export EDITOR

#for tcsh add to ~/.tcshrc
setenv EDITOR <path to pico>

Then (after a new login or resourcing of these files), whenever you type crontab -e, it will open in your favorite editor.

Have fun!
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
VPN: Debian Scripts -> Mandriva 2006 Scripts Undefined Mandriva 0 11-30-2005 12:10 PM
Need a scheduling App?? dikadika Linux - Software 2 04-05-2005 11:58 AM
Scheduling problems? mst700 Linux - Newbie 3 07-23-2004 09:23 PM
scheduling again nautilus_1987 Linux - Software 2 07-04-2003 07:53 AM
Scheduling Tasks? gauge73 Linux - General 1 01-28-2003 11:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:50 AM.

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