从现在起 8 小时后运行命令的简单方法是什么?我可以这样想:
nohup bash -c "sleep 28800 ; ./mycommand.sh" &
Run Code Online (Sandbox Code Playgroud)
有没有更“合适”的方法?
我需要psql命令行工具,但我不需要实际的 Postgres RDBMS。这是与支持 psql 接口的包一起使用的。
可以只安装psql吗?
(Ubuntu 16.04)
我想start.sh在运行这个的远程服务器上执行一个脚本:
nohup node server.js &
Run Code Online (Sandbox Code Playgroud)
天真地,我这样称呼 SSH:
ssh myserver <<EOF
./start.sh &
EOF
Run Code Online (Sandbox Code Playgroud)
这会启动脚本,但会保持会话处于连接状态。我想在脚本中使用其他命令执行此步骤,所以这不好。
如何通过 SSH 连接到远程机器,nohup在后台启动命令,然后断开连接?我想我可以将 SSH 进程本身置于后台,但这似乎不对。
从手册页:
-m, --ignore-missing, --fix-missing
Ignore missing packages; if packages cannot be retrieved or fail the integrity
check after retrieval (corrupted package files), hold back those packages and
handle the result.
Use of this option together with -f may produce an error in some situations. If a
package is selected for installation (particularly if it is mentioned on the
command line) and it could not be downloaded then it will be silently held back.
Configuration Item: APT::Get::Fix-Missing.
Run Code Online (Sandbox Code Playgroud)
这令人困惑:
在我的服务器上,它们都返回主机名:
$ ubuntu@mt-solo:~$ uname -n
myserver
$ ubuntu@mt-solo:~$ hostname
myserver
Run Code Online (Sandbox Code Playgroud)
总是这样吗?
来自man apt-get:
请注意,安静级别 2 意味着
-y; 你永远-d,--print-uris或者-s因为 APT 可能决定做一些你没有预料到的事情。
正如所建议的那样,这些选项实际上并没有安装任何东西。这有什么错用-qq为一个安静的替代品-y?
我有一台服务器可以运行一个小的 Django 应用程序。如果服务器重新启动,我希望 Django 重新启动:
nohup /opt/myapp/manage.py runserver ...
Run Code Online (Sandbox Code Playgroud)
我很难找到一种简单的方法来运行。有教程解释了如何编写成熟的服务、运行级别、init.d 等。但是一定有更简单的方法吗?一个我可以在其中添加一条额外线路的地方?
编辑马克的答案是完美的,单线的工作原理如下:
sudo sed --in-place '/^exit 0/i\cd /opt/appdir\npython manage.py runserver .... &' /etc/rc.local
Run Code Online (Sandbox Code Playgroud) apt ×2
background ×1
bash ×1
command-line ×1
hostname ×1
init.d ×1
logging ×1
nohup ×1
postgresql ×1
reboot ×1
runlevel ×1
schedule ×1
scripts ×1
ssh ×1
upstart ×1