Pra*_*har 4 shell scripting shell-script watch
我曾尝试使用 crontab,但仅限于几分钟。还有其他选择吗?
我也尝试过类似的事情:
watch -n 1 sh /path-to-script/try.sh
Run Code Online (Sandbox Code Playgroud)
但是每当我关闭终端时它就会停止。我想要一些在后台持续工作的东西。
使用带有while
循环和的脚本nohup
。
the_script.sh :
while :; do
/path-to-script/try.sh
sleep 1
done
Run Code Online (Sandbox Code Playgroud)
运行the_script.sh
不受挂断影响:
nohup /path/to/the_script.sh > /dev/null
Run Code Online (Sandbox Code Playgroud)
更换/dev/null
如果你关心什么是在一些文件路径stdout
。