在 Ubuntu 启动时执行脚本
/etc/rc.local并添加您的命令。exit 0重新启动 Ubuntu 时执行脚本
/etc/rc0.dsudo chmod +x script)在关闭时执行脚本
/etc/rc6.dsudo chmod +x script)注销时执行脚本
man bash对此有这样的说法:When a login shell exits, bash reads and executes commands from the file ~/.bash_logout, if it exists。因此,您可以将注销期间执行的脚本添加到~/.bash_logout.$HOME/.bash_logout才能etc/gdm/PostSession/Default使其正常工作。Jul*_*hau -1
这很简单。转到“系统”,然后转到“启动应用程序”(我没有英文版本 - 但您会注意到我的意思)。按“添加”按钮并简单地填写必要的内容。
如果您只想在关机时运行:制作一个带有 de shutdown 命令的脚本,但在此命令行之前执行您想要执行的任务。关闭/关闭 Ubuntu Linux
sudohalt 或 sudoshutdown-h now 重新启动 Ubuntu Linux sudoreboot
关机命令只能由 root 执行。更改关机命令,这是最简单的方法。