Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 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.

3  
Just put it into a screen or tmux session. It's reliable and easier than to fiddle with nohup and I/O redirection. –  SvW Apr 19 at 8:40
    
@SvW What if I need another screen session? The previous one will not be closed? –  Gabriel Santos Apr 19 at 8:44
1  
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. –  SvW Apr 19 at 8:49
    
@SvW Worked fine! (: –  Gabriel Santos Apr 19 at 8:56

1 Answer 1

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 Santos Apr 19 at 8:10
    
I can see the proccess when htop only before exit, but no after. –  Gabriel Santos Apr 19 at 8:11

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