I connect to a remote server, and run something like this:
cat /dev/zero > /dev/null & disown %-
Then I do logout
, and reconnect, and ps
shows no cat
process running. Why?
This command works on my end. It seems to take a lot of resources. Maybe you want to try:
sleep 999 & disown %-
and do a ps aux | grep sleep
after a relogin instead.
However, if you know that you want to disown the process before you start it, you could just use nohup:
nohup sleep 999
pid
during logout/login - have you tried it with sleep
?
Commented
Mar 21, 2017 at 17:20
ps
for some reason. It actually runs just fine. Any idea why doesn't it show for ps
from the same user that started it?
Commented
Mar 22, 2017 at 7:30
ps ux
should show it same user/same pid, except sleep
finished and terminated.
Commented
Mar 22, 2017 at 9:03
Use %%
or %+
for the "current" (most recently backgrounded) job. %-
is for the previous job, which is the second-most-recently stopped or backgrounded job. They mean the same thing if there's only one job. But if you'd left some background jobs running in an earlier part of your shell session or script, the way you're using %-
probably isn't targeting the job you think it is.
jobs
say?