0

I have an ubuntu server on AWS EC2. I can access it, with Putty and ssh, from a Windows 7 laptop. I would like to start a process up during one of these ssh sessions and have it continue after I have ended the ssh session. I thought that this could be done with nohup. However I try the following command on one ssh session.

nohup /var/www/Executables/inotifydropboxcopy &

I then do

ps | grep inotify

I get

27554 pts/0    00:00:00 inotifydropboxcopy 

However, when I open a new ssh session, to the same server, and type

ps | grep inotify

I get nothing. I also get nothing when I end the ssh session and start another.

How do I start a process that continues, on the server, between ssh sessions?

Edit:

I went into screen

screen

entered

 /var/www/Executables/inotifydropboxcopy &

Then detached from screen with ctrl-ad

Then, on the initial ssh session

ps | grep inotify

returned

27554 pts/0    00:00:00 inotifydropboxcopy

But, when I started up a new ssh session and entered

ps | grep inotify

I got nothing.

3
  • 1
    Use screen instead
    – roaima
    Jun 21, 2020 at 19:43
  • Thank you for your reply. I have edited my question to say what happened when I tried screen. It still does not appear to persist between ssh sessions. Thanks, Jun 21, 2020 at 20:18
  • "By default, ps selects all processes ... associated with the same terminal as the invoker.". If you run a remote ps from a new ssh session, the remote session has nothing to do with the previous ssh session. Jun 21, 2020 at 20:41

1 Answer 1

3

You should be able to see your output with ps -ax | grep inotify.

man ps with the a and x flags defined respectively.

Lift the BSD-style "only yourself" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like. The set of processes selected in this manner is in addition to the set of processes selected by other means. An alternate description is that this option causes ps to list all processes with a terminal (tty), or to list all processes when used together with the x option

Lift the BSD-style "must have a tty" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like. The set of processes selected in this manner is in addition to the set of processes selected by other means. An alternate description is that this option causes ps to list all processes owned by you (same EUID as ps), or to list all processes when used together with the a option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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