4

I am trying to start GUI application with upstart script on CentOS. I have test script located /etc/init/ folder.

start on desktop-session-start
stop on desktop-shutdown

respawn

script
export DISPLAY=:0
sleep 5
exec /.1/Projects/UpstartTest/start.sh &

end script

start.sh scripts is running binary files for GUI application.

After reboot my computer. When I typed:

[root@mg-CentOS ~]# initctl status test
test stop/waiting

So my upstart is not runnig. When i type

initctl start test

manually it works fine without any problem.

How can I run this upstart script after user login (desktop started) ? I am trying to find detailed documents for CentOS for upstart but there is no.

7

On 7 use gnome-session-properties to edit this in the GUI:

example

This will add a .desktop file in ~/.config/autostart/. You can also alternatively copy the .desktop file yourself.

1

I would hazard a guess that it fails to start because it has no X Session. Although you've told it to use DISPLAY:0 that display is currently used by you and not the upstart service.

Basically, upstart isn't designed for starting applications - it's designed to start system services.

Instead, you can create *.desktop entries in ~/config/autostart and I believe gnome-tweak-tool can also manage startup applications.

The *.desktop entry will be similar to:

[Desktop Entry]
Name=MyCoolScript
GenericName=A really cool script
Comment=Some description about your script
Exec=/.1/Projects/UpstartTest/start.sh
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true

More details on the spec is available at the Gnome developer website.

  • gnome-tweak-tool 3.8.1 on centos 7 does not do this. – chicks Oct 9 '15 at 20:34
1

Auto-start apps / services are scattered out there...

To list all Auto-Start Applications, search for autostart:

ls -1 "/etc/xdg/autostart" "/home/$USER/.config/autostart" \
"/usr/share/gdm/autostart"  "/usr/share/gnome/autostart"

To list all Auto-Start Services:

systemctl list-unit-files --type=service
# OR search for:
ls -1 /lib/systemd/system/*.service /etc/systemd/system/*.service

To list all Init scripts:

ls /etc/init.d/

To list all CronTab schedulers:

crontab -l 
# to edit run: crontab -e

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.