Run script on startup
Options
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
- 63 Announcements & News
- 48 Product News - New Product/Product Change Notice/ End-of-life
- 96 Welcome Developers!
- 45 Unboxing & Project Sharing
- 22 Tech Updates
- 3.4K UP Products
- 15 UP 7000
- 1 UP Squared i12
- 11 UP Xtreme i12
- 13 UP Squared Pro 7000
- 1 UP Element i12 Edge
- 23 UP Squared V2
- 65 UP 4000
- 23 UP Xtreme i11
- 34 UP Squared 6000
- 56 UP Squared Pro
- 136 UP Xtreme
- 820 UP Squared
- 1.4K UP Board
- 74 UP Core Plus
- 217 UP Core
- 3 UP Xtreme Lite
- 40 UP AI Edge
- 264 Starter Kits & Peripheral