Run script on startup

Thomas
New Member Posts: 18
Hello,
I would like to run the following simple script each time the up-board starts up
#!/bin/sh -
ifconfig wlan1 up
iwconfig wlan1 mode ad-hoc
iwconfig wlan1 essid "drone"
ifconfig wlan1 192.168.1.3 netmask 255.255.255.0
I put the following adhoc.service file in /lib/systemd/system and ran "systemctl daemon-reload" and "systemctl enable adhoc.service"
[Unit]
Description=SKYNET
After=
[Service]
ExecStart=/adhoc.sh
Restart=always
RestartSec=5s
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
When I reboot or start the script with "systemctl start adhoc.service" the status shows
Process: 4225 ExecStart=/adhoc.sh (code=exited, status=203/EXEC)
and the script never executes. I have made sure it is executable and it runs fine if I simply do ./adhoc.sh but using systemctl isn't working for some reason.
Can anyone see what might be going wrong? I would greatly appreciate anyones help with this!
Thanks,
Thomas
I would like to run the following simple script each time the up-board starts up
#!/bin/sh -
ifconfig wlan1 up
iwconfig wlan1 mode ad-hoc
iwconfig wlan1 essid "drone"
ifconfig wlan1 192.168.1.3 netmask 255.255.255.0
I put the following adhoc.service file in /lib/systemd/system and ran "systemctl daemon-reload" and "systemctl enable adhoc.service"
[Unit]
Description=SKYNET
After=
[Service]
ExecStart=/adhoc.sh
Restart=always
RestartSec=5s
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
When I reboot or start the script with "systemctl start adhoc.service" the status shows
Process: 4225 ExecStart=/adhoc.sh (code=exited, status=203/EXEC)
and the script never executes. I have made sure it is executable and it runs fine if I simply do ./adhoc.sh but using systemctl isn't working for some reason.
Can anyone see what might be going wrong? I would greatly appreciate anyones help with this!
Thanks,
Thomas
Comments
-
A common problem with scripts that run fine from your interactive shell, but fail when run from a start-up script, is that environment variables such as $PATH may have different values or are not set at all within the start-up environment.
I suggest, for example, using full absolute paths for the commands (e.g. 'iwconfig', etc.) you're running in your script. Or, alternatively, you can set a PATH variable at the top of your script for a similar effect. -
Thanks Dan! I put the script int /usr/bin/ since that is part of the $PATH and it works.
Much appreciated,
-Thomas
Categories
- All Categories
- 105 Announcements & News
- 54 Product News - New Product/Product Change Notice/ End-of-life
- 185 Welcome Developers!
- 55 Unboxing & Project Sharing
- 49 Tech Updates
- 693 UP Products
- 11 UP 7000
- 1 UP Squared i12
- 10 UP Xtreme i12
- 11 UP Squared Pro 7000
- 1 UP Element i12 Edge
- 19 UP Squared V2
- 59 UP 4000
- 24 UP Xtreme i11
- 35 UP Squared 6000
- 60 UP Squared Pro
- 143 UP Xtreme
- 837 UP Squared
- 1.4K UP Board
- 89 UP Core Plus
- 222 UP Core
- 3 UP Xtreme Lite
- 44 UP AI Edge
- 216 Starter Kits & Peripheral