在屏幕守护程序模式下运行命令
我正在尝试使用该命令在屏幕模式下运行命令
screen -dmS screen_name sed -i 's/a/b/'g some-file.txt
什么都没发生。 当我在脚本中放入相同的命令并运行命令时:
screen -dmS screen_name bash -c /path/to/script
有用。 我的问题是,我可以在守护进程模式下运行命令而无需先将其放入脚本中吗? 基本上,我需要这个守护进程function,因为它有助于并行运行多个命令,方法是将每个命令放在一个单独的屏幕守护程序上并行运行多个sed命令并在程序完成后自动终止。 谢谢
我想问题是-S如果你试图省略-S选项,它应该工作,即使没有bash -c所以试试这个
screen -dm sed -i 's/a/b/'g some-file.txt
这应该工作。 BTW屏幕未更新,您应该考虑切换到tmux。 它可以为您提供更多function。
您可以输入以下命令安装tmux:
sudo apt-get install tmux
所以你的代码应该是这样的:
tmux new-session -d -s foo 'sed -i 's/a/b/'g some-file.txt'
我可以测试一下
tmux new-session -d -s hello 'top'
如果你输入
tmux attach -t hello
它将带您进入顶级会议。 希望这会有所帮助。 校验
man tmux
所有function和检查全面的备忘单
这对你有用吗?
screen -dmS screen_name bash -c "sed -i 's/a/b/'g some-file.txt"