2017-11-03 161 views
-4

我正在使用基于LinuxDebian。有一个需要在启动时执行的脚本。找到these instructions describing on how it needs to be one。我唯一的区别是我需要在启动时使用参数运行脚本(myscript.sh --some-option 23)。我不能使用包装脚本。我不会解释为什么,但我只会说我不能。有谁知道该怎么做?在linux上使用参数执行脚本启动

+0

从'/ etc/rc.local'运行它?为systemd做一个服务单元来运行它? – AlexP

+0

您的系统是否在使用systemd? (例如,运行'systemctl'是否成功?) – negacao

回答

1

cron守护进程有一个@reboot命令。这会在重新启动时运行脚本。因此,简单地编辑你的crontab并添加一行这样的:

@reboot /your/script/test.sh 
+0

'cron'守护进程在我的系统上不可用。 – flashburn

+0

@flashburn什么阻止你安装某种cron? – Robert

0

假设你使用systemd的系统,这很容易。创建一个新的服务文件 “foo.service”:

[Unit] 
Description=Powertop autotune 

[Service] 
ExecStart=/usr/sbin/powertop --auto-tune # XXX replace with your command 

[Install] 
WantedBy=multi-user.target 

然后再进行安装:

ln -s /home/kris/Scripts/systemd/powertop.service /lib/systemd/system 
systemctl enable powertop 
systemctl start powertop 

显然你的路径和细节会有所不同。特别是,/lib/systemd/system可能并不适合您的发行版。