English
Ask Your Question
1

Systemd init script at boot

asked 2017-07-01 15:03:59 +0000

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 18:08:51 +0000

steveebey73742 gravatar image

updated 2017-07-01 18:12:26 +0000

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 ( 2017-07-01 19:18:16 +0000 )edit

Your Answer

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

Add Answer

[hide preview]

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers. If a question you asked has been answered, accept the best answer by clicking on the checkbox on the left side of the answer.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Question Tools

Follow
1 follower

Stats

Asked: 2017-07-01 15:03:59 +0000

Seen: 48 times

Last updated: Jul 01