在给定时间后杀死 nohup 进程

Kill nohup process after given time

我通过 SSH 在服务器上通过 nohup <command> & 启动命令,目前,我必须在给定时间后通过
手动终止进程 ps -ef | grep <command> kill <pid>

有没有办法在给定时间后对以 nohup 启动的进程使用某种超时?

最好的方法是在 Ubuntu.

上使用单线
nohup timeout 10 ping google.com &

没有太多的解释。 nohup x & 即使终端关闭,也会在后台运行命令。 timeout y y 秒后自动终止命令。整洁