Welcome to the Linux Foundation Forum!

Schedule process while shutdown & Restart

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

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Posts: 216
    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?
  • hi,

    I am trying to schedule a job while shutdown/restart in RHEL 5.
  • Posts: 216
    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.
    1. #!/bin/sh
    2. stop(){
    3. echo $0 > /tmp/job.log
    4. }
    5. case $1 in
    6. stop)
    7. stop
    8. ;;
    9. *)
    10. esac
    11. exit 0

    Make it executable:
    1. chmod 0755 /etc/rc.d/init.d/job

    Make a "kill" symlink for it in /etc/rc.d/rc6.d:
    1. 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:
    1. 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.
  • Posts: 2
    Awesome, this is solid help.

    Thanks!

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training