Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, I'm totally new to Linux scripting and I need a script that every day runs a program on a specified time and stop it on another specified time.It ...
  1. #1
    Just Joined!
    Join Date
    Aug 2008
    Posts
    3

    Program rerun scrip

    Hi all,
    I'm totally new to Linux scripting and I need a script that every day runs a program on a specified time and stop it on another specified time.It should also have the ability to set it for every weak or month (besides every day) and specified date and time.

    Does any one have such script? or could you help me on how to write it?

    Thanks

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    In bash, the basic thing would be something like this:

    Code:
    #!/bin/bash
    
    #change this for the program/command to run
    <my command>&
    pid_of_my_command=$!
    sleep <whatever_time>
    kill -SIGKILL $pid_of_my_command
    To start it, you can use the cron or at daemons. Cron, by default, has folders under /etc/cron* to run things hourly, daily, weekly,.... It should stop without a problem when sleep ends (use man sleep to see the manual page for that command to customize the time).

    That's the basic idea.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...