1

I start a command via nohup <command> & on the server via SSH and currently, I have to manually kill the process after a given time via
ps -ef | grep <command> kill <pid>

Is there a way to use some kind of timeout with a process started with nohup after a given time?

Best way would be a one-liner that works on Ubuntu.

S Osten
  • 15
  • 1
  • 5

1 Answers1

2
nohup timeout 10 ping google.com &

Not really much explanation to give. nohup x & runs the command in the background even if the terminal is closed. timeout y autokills the command after y seconds. Neat.

jeremysprofile
  • 10,028
  • 4
  • 33
  • 53