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


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.

5 Answers 5


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


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


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
  • 1
    This is a fantastic answer if you're using the command line. Jan 6, 2020 at 0:25
  • Do all services from /etc/init.d/ start at boot?
    – Danijel
    Mar 19, 2021 at 10:10

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]
GenericName=A really cool script
Comment=Some description about your script

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, 2015 at 20:34

Using cron worked for me on my Centos 7 server.

# enter crontab edit
crontab -e

# place this inside the cron file you opened with the previous command
@reboot /path/to/your/script.sh

Remember to make your script executable.


The picture shows my CentOS7 machine runnning the MATE destkop.

The command in the terminal:


Works for those users running the MATE desktop, it opens up the 'Startup Application Preferences' tab, click the ADD button and enter the name/launch command/comment. I have used the example of Google Chrome and that command runs it for me.

For gnome users, the command in the terminal:


Brings up the same dialogue for gnome.

The picture shows my CentOS7 machine runnning the MATE destkop.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .