0

I'm running a script (in a Laravel project) that takes a few hours to complete. nohup to prevent it from exiting if my ssh session is disconnected.

nohup php artisan do:thing 2>&1 | tee ~/tmp 

It starts off nicely, but after some time, I get a broken pipe error and it stops outputing things, and tee stops as well - the doc stops at that point.

I guess it's because the tee process got killed by the ssh session drop? Can I prevent it?

Could I maybe disown the tee process and prevent ssh from terminating it?

0

1 Answer 1

3

The nohup applies to the first command. When you close your shell the tee no longer can write to its normal output (stdout) and exits. This causes the first command to exit because it now too can no longer write to its pipe output.

Try this

nohup php artisan do:thing >~/tmp 2>&1 

Or if you have screen,

screen sh -c 'php artisan do:thing 2>&1 | tee ~/tmp' 
4
  • Thanks, I'll try it! I didn't know I could specify two different outputs that way. Interesting Commented Jan 11, 2024 at 8:21
  • @JeremyBelolo that's what tee does. See the description in the first paragraph of the documentation/manual, man tee Commented Jan 11, 2024 at 8:48
  • Got myself a rtfm. Probably well deserved :D Thanks! Commented Jan 11, 2024 at 8:58
  • 1
    I don't use that expression myself. The documentation is decidedly reference material not tutorials. You have to know what you're looking for Commented Jan 11, 2024 at 9:07

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.