有不止一种方法可以实现这一点。
您可以将启动脚本放入/etc/init.d
并使其类似于那里的现有脚本之一。但是根据您的 Linux 舒适度,这可能有点令人生畏。
您可以将其设为服务并在启动时启动该服务。只需在 Google 上搜索“如何使我的程序成为服务”,您就会看到很多页面。不仅仅是你可以摇晃棍子的东西。
如果您的应用程序使用单个命令启动并且不依赖于其他任何东西,您可以在/etc/rc.local
文件末尾添加启动命令。
您也可以将它放在 cron 中以在启动时执行,但在我看来,这不是应该的方式
Ubuntu 通常安装了 Vixie cron。您可以对普通用户的crontab
文件使用@reboot。从手册页:
Instead of the first five fields, one of eight special strings may
appear:
string meaning
------ -------
@reboot Run once, at startup.
....
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16912 次 |
最近记录: |