Results 1 to 3 of 3

Thread: Shutdown program after set time

  1. #1
    Join Date
    Aug 2016
    Location
    El Lago, Texas
    Beans
    746
    Distro
    Ubuntu Mate

    Shutdown program after set time

    Is there a way to shut down a program after a set amount of time?

    For example: Start Seamonkey and have it close after one hour.

    This does not work.

    Code:
    #!/bin/bash
    # Ubuntu_Mate 18.04 LTS
    #
    #
    seamonkey
    sleep 1
    killall seamonkey
    Last edited by raleigh3; July 19th, 2018 at 09:03 PM.
    Ubuntu Mate 18.04 Bionic and Ubuntu Mate 20.04
    Mate Desktop

  2. #2
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Shutdown program after set time

    For a start, that script would kill it only 1 second after starting it, not one hour as you say you want.
    From man sleep:
    sleep NUMBER[SUFFIX]...

    Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd'
    for days.
    Have you tried
    Code:
    #!/bin/bash
    seamonkey
    sleep 1h; killall seamonkey
    or just use a simple compound command
    Code:
    seamonkey & sleep 1h; killall seamonkey

  3. #3
    Join Date
    Aug 2016
    Location
    El Lago, Texas
    Beans
    746
    Distro
    Ubuntu Mate

    Re: Shutdown program after set time

    Thanks. Both methods worked.
    Ubuntu Mate 18.04 Bionic and Ubuntu Mate 20.04
    Mate Desktop

Bookmarks

Posting Permissions

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