Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running the following command in a loop (without notable memory leaks) as a cPanel user:

nohup php ~/www/app/console.php run clean 1> /dev/null 2> ~/www/logs/run_clean.log &

But when I exit SSH, the command always stops. When I do a htop as root, I can't see the process running.

If I don't exit the SSH for days, for instance, the process will continue running fine!

What is wrong? Is not expected for the command I have posted to run in the background without interruption?

share|improve this question

closed as off-topic by Jenny D, Falcon Momot, mdpc, Wesley, Rex Apr 20 '14 at 3:00

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – Jenny D, mdpc, Wesley, Rex
If this question can be reworded to fit the rules in the help center, please edit the question.

Just put it into a screen or tmux session. It's reliable and easier than to fiddle with nohup and I/O redirection. – Sven Apr 19 '14 at 8:40
@SvW What if I need another screen session? The previous one will not be closed? – Gabriel Apr 19 '14 at 8:44
No, it will not be closed. You can have multiple screen sessions with multiple windows open for each. Read about how screen works. It's a godsend and about the most useful tool for remote work next to ssh. – Sven Apr 19 '14 at 8:49
@SvW Worked fine! (: – Gabriel Apr 19 '14 at 8:56

The command might detect its stdin being closed at logout. Try redirecting it from /dev/null:

nohup php ~/www/app/console.php run clean 1> /dev/null 2> ~/www/logs/run_clean.log  </dev/null &
share|improve this answer
It says "exit", when I exit, without command stdin. – Gabriel Apr 19 '14 at 8:10
I can see the proccess when htop only before exit, but no after. – Gabriel Apr 19 '14 at 8:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.