[英]Running a script with upstart server in ubuntu 14.04
I have a script named rotate.sh . 我有一个名为rotate.sh的脚本。 After chmod +x rotate.sh
, I can run it with the command /home/lin/Desktop/rotate.sh
, and my screen will rotate left. 在chmod +x rotate.sh
,我可以使用命令/home/lin/Desktop/rotate.sh
运行它,并且我的屏幕将向左旋转。
rotate.sh: rotation.sh:
#!/bin/bash
xrandr --output VGA1 --rotate left
Then I write a upstart job named testOne , located in /etc/init/testOne.conf . 然后,我在/etc/init/testOne.conf中编写了一个名为testOne的新贵工作。
testOne.conf: testOne.conf:
description "test upstart job"
author "Lin a@i.com"
start on filesystem or runlevel [2345]
start on desktop-session-start
stop on shutdown
pre-start script
mkdir -p /home/lin/Desktop/test1
end script
respawn
respawn limit 15 5
script
exec /home/lin/Desktop/rotate.sh
cd /home/lin/Desktop/
mkdir test2
end script
But when I run sudo start testOne
, it doesn't work. 但是当我运行sudo start testOne
,它不起作用。 Only the pre-start works. 仅预启动有效。 What am I doing wrong? 我究竟做错了什么?
Perhaps changing this line 也许改变这条线
exec /home/lin/Desktop/rotate.sh
to 至
exec /home/lin/Desktop/rotate.sh start
would help. 有助于。 As an alternative, you can also use exec stanzas instead of simple cases, in which case, it would be something like this 或者,您也可以使用exec节代替简单的情况,在这种情况下,将是这样的
exec bash -c '/home/lin/Desktop/rotate.sh start'
Check out some reference here on upstart and how to work with it: http://upstart.ubuntu.com/cookbook/#id300 在此处查看有关新贵及其使用方法的参考: http : //upstart.ubuntu.com/cookbook/#id300
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.