Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I use JDownloader to get huge files from the internet when I'm afk. The problem is when I'm too afk the computer is still ON even if the downloads ...
  1. #1
    Just Joined!
    Join Date
    Sep 2011
    Posts
    3

    Question Halt computer when a program stops running

    Hi,
    I use JDownloader to get huge files from the internet when I'm afk.
    The problem is when I'm too afk the computer is still ON even if the downloads are finished.
    Now JDownloader has a functionality that exits the program when all downloads are finished; so I need your help guys to find a way to shutdown the computer once JDownloader is not running anymore.
    Thanks...

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,977
    Write a script that monitors JDownloader and switches the system to runlevel 0 (halt) when it terminates.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Sep 2011
    Posts
    3
    That might be the way. Any idea how to do it?

  4. #4
    Linux Guru
    Join Date
    May 2011
    Posts
    1,855
    assuming the prog is called JDownloader...
    Code:
    #!/bin/bash
    pid=$(pidof -x JDownloader)
    if [ -n "$pid" ]; then
      echo "JDownloader (pid $pid) still running..."
    else
      echo JDownloader is not running
      echo halting
    #shutdown -h now
    fi

  5. #5
    Just Joined!
    Join Date
    Sep 2011
    Posts
    3
    Quote Originally Posted by atreyu View Post
    assuming the prog is called JDownloader...
    Code:
    #!/bin/bash
    pid=$(pidof -x JDownloader)
    if [ -n "$pid" ]; then
      echo "JDownloader (pid $pid) still running..."
    else
      echo JDownloader is not running
      echo halting
    #shutdown -h now
    fi
    I was expecting a loop or something...
    Or is it possible to use cron to run the script every X minutes?

  6. #6
    Linux Guru
    Join Date
    May 2011
    Posts
    1,855
    yeah, cron it or wrap it inside:

    Code:
    while :; do
    ...
      sleep 1
    done

Posting Permissions

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