First of all, the easiest way to run things at startup is to add them to the file /etc/rc.local.
Another simple way is to use @reboot in your crontab. Read the cron manpage for details.
However, if you want to do things properly, in addition to adding a script to /etc/init.d you need to tell ubuntu when the script should be run and with what parameters. This is done with the command update-rc.d which creates a symlink from some of the /etc/rc* directories to your script. So, you'd need to do something like:
update-rc.d yourscriptname start 2
However, real init scripts should be able to handle a variety of command line options and otherwise integrate to the startup process. The file /etc/init.d/README has some details and further pointers.
发布评论
评论(1)
首先,在启动时运行事物的最简单方法是将它们添加到文件
/etc/rc.local
。另一种简单的方法是使用
@在 crontab 中重新启动
。有关详细信息,请阅读 cron 联机帮助页。但是,如果您想正确执行操作,除了向
/etc/init.d
添加脚本之外,您还需要告诉 ubuntu 该脚本何时运行以及使用哪些参数。这是通过命令update-rc.d
完成的,该命令创建从某些/etc/rc*
目录到脚本的符号链接。因此,您需要执行以下操作:但是,真正的初始化脚本应该能够处理各种命令行选项,并以其他方式集成到启动过程中。文件
/etc/init.d/README
有一些详细信息和进一步的指示。First of all, the easiest way to run things at startup is to add them to the file
/etc/rc.local
.Another simple way is to use
@reboot
in your crontab. Read the cron manpage for details.However, if you want to do things properly, in addition to adding a script to
/etc/init.d
you need to tell ubuntu when the script should be run and with what parameters. This is done with the commandupdate-rc.d
which creates a symlink from some of the/etc/rc*
directories to your script. So, you'd need to do something like:However, real init scripts should be able to handle a variety of command line options and otherwise integrate to the startup process. The file
/etc/init.d/README
has some details and further pointers.