LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-31-2011, 08:45 AM   #1
elieobeid7
LQ Newbie
 
Registered: Jul 2011
Posts: 21

Rep: Reputation: Disabled
Shell scripting cron jon


I have a radio and would like to run a specific playlist on fridays.

so on fridays 8 pm i would like to execute this command

cd /home/shoutcast/shoutcast/sc_trans/killall -9 ./sc_trans./sc_trans oldies.conf &

then on 9 pm i would like to execute this one

cd /home/shoutcast/shoutcast/sc_trans/killall -9 ./sc_trans./sc_trans &

this changes the playlist to be played on shoutcast, how to schedule these commands, I'm on centos 5
 
Old 08-31-2011, 09:23 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 2,992

Rep: Reputation: 737Reputation: 737Reputation: 737Reputation: 737Reputation: 737Reputation: 737Reputation: 737
You would use the crontab utility to set both up:
Code:
crontab -e
is how you do that (as "you"). The -e "edit crontab for user."

Now, what the heck do you do, eh?

If you look at the manual page for crontab there are examples that may prove useful. What you want to do is execute a command at 20 hours on Friday then execute another command at 21 hours on Friday which would look something like this
Code:
0 20 * * fri command
0 21 * * fri command
Now, in the above, command can be a shell program (rather than the long lines you have above); what you could do is save your first command line as a shell program named, oh, say, startit and that other as, what the heck, stopit and that might make things easier for you to keep track of (and if you ever have to edit either one...).

The fields in crontab are
Code:
MIN HOUR DAY MONTH DAY_OF_WEEK Command
Minutes are 0-59, hours are 0-23, Day is the day of the month, Day of the week is the three-character abbreviation, and Command is what to execute. Be sure to peruse the manual page for more details and examples.

Note that you really do need to look at the manual page for your distribution -- crontab varies from system-to-system and may not be identical on all.

Hope this helps some.
 
1 members found this post helpful.
Old 08-31-2011, 09:31 AM   #3
elieobeid7
LQ Newbie
 
Registered: Jul 2011
Posts: 21

Original Poster
Rep: Reputation: Disabled
thank you
 
Old 08-31-2011, 09:57 AM   #4
elieobeid7
LQ Newbie
 
Registered: Jul 2011
Posts: 21

Original Poster
Rep: Reputation: Disabled
sir just one more thing, how to save and ext contab-e

i tried every method listed here and none works

http://www.computing.net/answers/sol...tab-e/313.html

i have a centos 5, vi come by default with yum and i installed nano

Last edited by elieobeid7; 08-31-2011 at 09:59 AM.
 
Old 08-31-2011, 09:02 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,225

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
crontab -e invokes the default editor in $EDITOR in your env; usually vi/vim.
The editor creates a temp file copy for you to edit and puts you in there.
When you exit-with-save the editor normally eg ':x' for vi/vim, crontab will collect the temp file and use it to overwrite the real crontab file. It also notifies the cron dameon.
For the paranoid, create a test user and experiment.
 
  


Reply

Tags
shell script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
LXer: Terminal functions for shell scripting with Shell Curses LXer Syndicated Linux News 0 03-26-2008 11:50 PM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
Questions about shell scripting and cron jobs carlito11973 Programming 2 10-06-2006 10:34 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM


All times are GMT -5. The time now is 06:13 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration