LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-25-2011, 06:33 AM   #1
r4jiv007
LQ Newbie
 
Registered: Nov 2010
Location: India
Distribution: Ubuntu;Fedora;Mint
Posts: 11

Rep: Reputation: 0
Question How to Schedule a program in linux ??


hi der !!

i wanted to run an application every-time i issue a shutdown command ...
i mean the app will execute first and then the system will shutdown.

i searched a bit and every time i found at command which i think is not applicable here

is there any way to edit the shutdown menu!!!!
Any suggestion for that !!!!!
 
Old 10-25-2011, 06:46 AM   #2
nenpa8lo
Member
 
Registered: Oct 2008
Location: Ireland
Distribution: Slackware 13.0, Slackware 13.37
Posts: 68
Blog Entries: 2

Rep: Reputation: 18
If I'm not mistaken this is how you do it:
Code:
ln -s /etc/init.d/<script> /etc/rc.d/rc5.d/K50<script>
K50<script> should execute it at shutdown.
 
Old 10-25-2011, 08:30 AM   #3
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by r4jiv007 View Post
hi der !!

i wanted to run an application every-time i issue a shutdown command ...
i mean the app will execute first and then the system will shutdown.

i searched a bit and every time i found at command which i think is not applicable here

is there any way to edit the shutdown menu!!!!
Any suggestion for that !!!!!
you need to add your script in the following file
Code:
#cp example.sh /etc/init.d/

#ln -s /etc/init.d/example.sh /etc/rc0.d/K10example.sh  ------->0 runlevel for poweroff
#ln -s /etc/init.d/example.sh /etc/rc6.d/K10example.sh  ------->6 runlevel for restart
 
Old 10-25-2011, 09:32 AM   #4
r4jiv007
LQ Newbie
 
Registered: Nov 2010
Location: India
Distribution: Ubuntu;Fedora;Mint
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by deep27ak View Post
you need to add your script in the following file
Code:
#cp example.sh /etc/init.d/

#ln -s /etc/init.d/example.sh /etc/rc0.d/K10example.sh  ------->0 runlevel for poweroff
#ln -s /etc/init.d/example.sh /etc/rc6.d/K10example.sh  ------->6 runlevel for restart

what if i want to execute a binary file not the shell script ??
and can u please explain me your lines atleast give me a breif
thanks
 
Old 10-25-2011, 04:14 PM   #5
nenpa8lo
Member
 
Registered: Oct 2008
Location: Ireland
Distribution: Slackware 13.0, Slackware 13.37
Posts: 68
Blog Entries: 2

Rep: Reputation: 18
You have to make a symbolic link 'ln -s' (google) to your script as deep27ak pointed out. If you want to run executable then the fastest way for you would be having a script which executes your binary
Code:
#/bin/bash
/path/to/your/binary/actualbinary
should do. Remember to give your scirpt .sh and make it executable (chmod command - google).

Last edited by nenpa8lo; 10-25-2011 at 04:16 PM.
 
Old 10-27-2011, 01:31 AM   #6
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by r4jiv007 View Post
what if i want to execute a binary file not the shell script ??
and can u please explain me your lines atleast give me a breif
thanks

there are files by the name of rc0, rc.1, rc.2 ....
and directories by the name of rc0.d, rc1.d rc2.d ........

which contains the services to be started
Code:
The naming is done on the basis of run level i.e. 
run level 0----> rc0.d
run level 5----> rc5.d
'K' and 'S' scripts are used to represent the type of execution
scripts starting with K are executed before S scripts
S stands for start and K stands for stop

Quote:
every file inside rcx.d is linked in /etc/init.d
So put your file in rcx.d and create a link to init.d
if you want to execute a binary file make it executable and do as I mentioned

best of luck
 
1 members found this post helpful.
Old 10-28-2011, 03:13 AM   #7
r4jiv007
LQ Newbie
 
Registered: Nov 2010
Location: India
Distribution: Ubuntu;Fedora;Mint
Posts: 11

Original Poster
Rep: Reputation: 0
Talking

Quote:
Originally Posted by deep27ak View Post
there are files by the name of rc0, rc.1, rc.2 ....
and directories by the name of rc0.d, rc1.d rc2.d ........

which contains the services to be started
Code:
The naming is done on the basis of run level i.e. 
run level 0----> rc0.d
run level 5----> rc5.d
'K' and 'S' scripts are used to represent the type of execution
scripts starting with K are executed before S scripts
S stands for start and K stands for stop



if you want to execute a binary file make it executable and do as I mentioned

best of luck

thanks man that was a good brief description .......

can you provide me link or somthing to know this kinda stuffs ..... it will be very helpful to me
thanks again
 
Old 10-28-2011, 03:20 AM   #8
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by r4jiv007 View Post
thanks man that was a good brief description .......

can you provide me link or somthing to know this kinda stuffs ..... it will be very helpful to me
thanks again
this is something which you can easily get on google

I am sure you will get a bunch of sites including Wikipedia to help you out

and if you think your problem is fixed mark the thread as solved
 
  


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
Usage of AT Command to Schedule a Program gartura Linux - General 5 05-13-2010 04:32 PM
schedule program hewittrj Linux - Software 1 08-21-2007 10:59 PM
LXer: Schedule Tasks Using Gnome-schedule (cron & at GUI) LXer Syndicated Linux News 0 07-28-2007 12:31 AM
schedule program omerlh Programming 5 01-12-2006 04:41 AM
Schedule a graphic program juanczm Linux - General 1 01-28-2005 03:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:03 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