Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 14 of 14
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,847
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  2. #12
    I have looked at those sites, but they did not help, I cant get the "at now + 1 min" to go along with start, stop or restart a process.
    To start a process I just write the path to it, and I have to use the PID to kill it, is there any other way? to start, stop and restart using 'at'?

  3. #13
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,847
    I'm not too familiar with 'at' but I would do something like invoke a script via 'crontab' file.

    The script will do the following

    1)Start the process-A
    2)Get pid of the process using 'echo $!'
    2.1)Sleep for 120 seconds
    3) kill the process id obtained in step 2
    4)Start the process again
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  4. $spacer_open
    $spacer_close
  5. #14
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,907
    Taking the Apache web server as an example I can do the following as root:

    Code:
    at now +2 min<ENTER>
    systemctl restart apache2<ENTER>
    <CTRL+D>
    This schedules a restart of the web server in 2 minutes. I am using openSUSE, please bear in mind that the command you are scheduling (the systemctl line) may vary by distro. For example, if I recall correctly, the same thing in Red Hat is:

    Code:
    at now +2 min<ENTER>
    service httpd restart<ENTER>
    <CTRL+D>
    You could write a simple script, or indeed a not so simple one, as a normal user. For example in a file called test.sh in your ~/Documents/scripts directory which you can create if you don't have one.
    Code:
    #!/bin/bash
    mkdir test
    cd test
    echo "Hello world" > hello.txt
    You will need to mark the script as executable using
    Code:
    chmod +x test.sh
    And then to have it run in two minutes you would do the following. In openSUSE this operates under the scripts directory. You end up with a file called ~/Documents/scripts/test/hello.txt. If you are wondering, ~ is the current user's home directory, in my case /home/elija/
    Code:
    at now +2 min<ENTER>
    ~/Documents/scripts/test.sh<ENTER>
    <CTRL+D>
    Last edited by elija; 05-29-2013 at 03:37 PM. Reason: Forgot to mark it executable among other things!
    Should you be sitting wondering,
    Which Batman is the best,
    There's only one true answer my friend,
    It's Adam Bloody West!


    The Fifth Continent

Posting Permissions

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