Linux.com

Home Linux Community Forums New to Linux Getting Started with Linux Schedule process while shutdown & Restart

Schedule process while shutdown & Restart

Link to this post 05 Jun 09

Dear All,

Greetings to All,

I have a doubt in scheduling job while restarting and shutdowning in RHEL 5. Can any help me to do this?

Regards,

Karthikeyan.N

Link to this post 05 Jun 09

gnkarthikeyann wrote:

Dear All,

Greetings to All,

I have a doubt in scheduling job while restarting and shutdowning in RHEL 5. Can any help me to do this?

Regards,

Karthikeyan.N

I'm sure someone here can help - can you go into more detail about what your prob is? Are you trying to schedule shutdowns/restarts, or are you scheduling some other job that is conflicting with shutdowns/restarts, or something else?

Link to this post 08 Jun 09

hi,

I am trying to schedule a job while shutdown/restart in RHEL 5.

Link to this post 09 Jun 09

gnkarthikeyann wrote:

hi,

I am trying to schedule a job while shutdown/restart in RHEL 5.

Okay, try this for starters. Create a test script, i'll call it "job", that takes "stop" as an argument, and put it in /etc/rc.d/init.d/ (or /etc/init.d/). Have it do something simple, like write something to a log: e.g.


#!/bin/sh
stop(){
echo $0 > /tmp/job.log
}
case $1 in
stop)
stop
;;
*)
esac
exit 0

Make it executable:

 chmod 0755 /etc/rc.d/init.d/job

Make a "kill" symlink for it in /etc/rc.d/rc6.d:

 ln -s /etc/rc.d/init.d/job /etc/rc.d/rc6.d/K99job

the "K" in the beginning of the link name indicates that the script will be called with the "stop" arg when the system reboots/halts. The number after the K is the order in which it will get executed (1 = first, 99 = last).

IMPORTANT: there must be a file (can be empty) in /var/lock/subsys with the same name as your init script (job). so before testing, do this:

 touch /var/lock/subsys/job

Ideally, this file should get created when your job first gets started. Or if there is no such job already running, you can put this in /etc/rc.d/rc.local, and will get created every time the system comes up.

Link to this post 10 Jul 09

Awesome, this is solid help.

Thanks!

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board