2

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?

3

2 Answers 2

1

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
4
  • It is possible that in your case user is still logged in somewhere. In mine, when I log off, nobody else is logged in.
    – RomaValcer
    Commented Mar 21, 2017 at 16:59
  • No, the process is detached from the shell and keeps it's pid during logout/login - have you tried it with sleep ?
    – Michael D.
    Commented Mar 21, 2017 at 17:20
  • Apparently, it just didn't show when I did 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?
    – RomaValcer
    Commented Mar 22, 2017 at 7:30
  • No, ps ux should show it same user/same pid, except sleep finished and terminated.
    – Michael D.
    Commented Mar 22, 2017 at 9:03
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .