Ask Your Question
1

Systemd init script at boot

asked 2017-07-01 10:03:59 -0500

jpec57 gravatar image

Hello,

As a real beginner in programming, I yet decided to create my own script which I want to be loaded at boot.

To begin with, I have created a file in /usr/bin named "ini" containing the following lines :

!/bin/sh

gedit /home/Jpec/todolist

I runned "chmod 777 ini" and already succeeded at launching the script.

Then, I went to /etc/systemd/system where I created "ini.service":

[Unit] Description=My FirstInitScript

[Service] Type=simple ExecStart=/usr/bin/ini RemainAfterExit=yes

[Install]

WantedBy=default.target

Finally, I've run the commands "systemctl start ini" and "systemctl status ini", but it only resulted in the following output :

Loaded: loaded (/etc/systemd/system/ini.service; enabled; vendor preset: disa Active: active (exited) (Result: exit-code) since sam. 2017-07-01 16:40:59 CE Process: 872 ExecStart=/usr/bin/ini (code=exited, status=203/EXEC) Main PID: 872 (code=exited, status=203/EXEC) Tasks: 0 (limit: 4915)

CGroup: /system.slice/ini.service

I'm really lost in all of this and I cannot think of one thing to do to correct this after seeing loads of topics... Could you help me to locate my mistakes ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-07-01 13:08:51 -0500

steveebey73742 gravatar image

updated 2017-07-01 13:12:26 -0500

You might consider making an autostart, in your desktop control environment, instead of a boot script to open the text editor. You may not have all the file services mounted when the script runs, and it either can not find your /home or the gedit service is failing to provide an exit code, as it is a gui text editor. Put the run command gedit /home/Jpec/todolist in the autostart, and once you login to your desktop, then it should work fine. If all you want to do, is display the file, on bootup, then change gedit to cat in your current script, and see if that produces results.

edit flag offensive delete link more

Comments

Services in "systemd/system" do not have access to your desktop or terminal, so interactive programs cannot be run this way,

villykruse gravatar imagevillykruse ( 2017-07-01 14:18:16 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-07-01 10:03:59 -0500

Seen: 160 times

Last updated: Jul 01 '17