You are not logged in.

#1 2012-09-22 22:12:42

Jayfree
Member
Registered: 2012-09-22
Posts: 5

[SOLVED]Starup sript not getting executed in systemd

Hello All,

I have a script(rpi_user.sh) which has to be executed every time when I start my computer. But the startup script is not executing. Following are the steps which I have done. I am using systemd. I upgraded my system successfully today.

The script which I wanted to execute was very small and easy. I just creates a new file with the echoed text. Below is my script(rpi_user.sh)
cd /home/pi/
echo Jeffrey > 1

When ever I restart my system, I am not able to see the file '1'

I made the startup script(rpi_user.sh) and kept in /usr/bin. Also I followed the instruction in https://wiki.archlinux.org/index.php/Sy … process.3F

Below shown in my service file (rpi_user.service)
[Unit]
Description=rpi_user

[Service]
ExecStart=/usr/bin/rpi_user.sh

[Install]
WantedBy=multi-user.target

After creating rpi_user.sh, I executed the following command to make the file executable - chmod +x rpi_user.sh

Once completing these steps, I executed the following commands (I got these info from http://forum.teamspeak.com/showthread.p … up-script)
# systemctl --system daemon-reload
# systemctl start rpi_user.service
# systemctl enable rpi_user.service
# systemctl status rpi_user.service

But things didn't go fine. When I ran "systemctl status rpi_user.service", I got the following error

rpi_user.service - rpi_user
      Loaded: loaded (/etc/systemd/system/rpi_user.service; enabled)
      Active: failed (Result: exit-code) since Sun, 23 Sep 2012 03:29:08 +0530; 1min 33s ago
    Main PID: 247 (code=exited, status=203/EXEC)
      CGroup: name=systemd:/system/rpi_user.service

Sep 23 03:29:08 alarmpi systemd[247]: Failed at step EXEC spawning /usr/bin/rpi_user.sh: Exec format error

Could anyone of you answer the following questions.
1) Is there any thing wrong which I have done ? Is this the way to create startup scripts ?
2) Could you help me in fixing the issue - how can I make my starup script run ?

Thanks and Best Regards,
Jeffrey Antony
www.jeffrey.co.in

Last edited by Jayfree (2012-09-23 10:31:43)

Offline

#2 2012-09-22 22:29:15

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]Starup sript not getting executed in systemd

Are you using Arch Linux ARM? If so, you should ask for help with your Raspberry Pi on their forum: http://archlinuxarm.org/forum/viewforum … 7e879cb1e3

Offline

#3 2012-09-22 22:57:03

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: [SOLVED]Starup sript not getting executed in systemd

Did you include

#!/bin/sh -

as the first line of your script?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#4 2012-09-23 04:22:46

Jayfree
Member
Registered: 2012-09-22
Posts: 5

Re: [SOLVED]Starup sript not getting executed in systemd

@karol: I agree it is an raspberry pi. But once ArchLinux is installed, it doesnot make much difference whether it is an RaspberryPi or an Pentium machine. Thats the reason I posted the question here. But anyways I will post it in ArchRpi forum also.

@cfr: Yes. I have added #!/bin/sh. But the result is same. I get the same error. What is the need of "-" in "#!/bin/sh -" ? I didnot add "-".

Regards,
Jeffrey

Offline

#5 2012-09-23 10:30:41

Jayfree
Member
Registered: 2012-09-22
Posts: 5

Re: [SOLVED]Starup sript not getting executed in systemd

Hello All,

The issue is fixed. After my restart things are working fine. I think I missed to add #!/bin/sh in the beginning of the script file.

@cfr: Special thanks for your suggestion.

Regards,
Jeffrey

Offline

#6 2012-09-23 14:04:57

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: [SOLVED]Starup sript not getting executed in systemd

Jayfree wrote:

What is the need of "-" in "#!/bin/sh -" ? I didnot add "-".

A book I read on shell scripting recommended this as one way of increasing the security of shell scripts as it prevents options being parsed as arguments. I doubt it matters here - I've just developed a habit of writing it that way.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB