Program starts from rc.local but doesn't do anything
0
votes
2
answers
291
views
I have a program which uses msqllib. It scans some hardware that I build and then updates a mysql database. This program has been running for a number of years but I have never been able to autostart it when the system reboots.
Now I have an issue with power cycling that is beyond my control, so want to get it running automaticaly.
In rc.local : I have:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
/home/nigel/scan
exit 0
Now, the code runs fine when I enter it at a command prompt, and updates my database. However, when I put it in rc.local,
ps -ef
shows:
root 356 350 0 20:54 ? 00:00:03 /home/nigel/scan
but the program is not executing the SQL calls to update the database.
If I ask for the statius of rc.local:
root@Pi-Scan:~# systemctl status rc-local.service
● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; vendor preset: enabled)
Drop-In: /usr/lib/systemd/system/rc-local.service.d
└─debian.conf
/etc/systemd/system/rc-local.service.d
└─ttyoutput.conf
Active: activating (start) since Sat 2023-05-06 20:54:19 EDT; 12min ago
Docs: man:systemd-rc-local-generator(8)
Cntrl PID: 350 (rc.local)
Tasks: 2 (limit: 414)
CPU: 3.903s
CGroup: /system.slice/rc-local.service
├─350 /bin/sh -e /etc/rc.local start
└─356 /home/nigel/scan
May 06 20:54:21 Pi-Scan rc.local: error: first parameter is not a valid address family: Transport endpoint is not connected
May 06 20:54:22 Pi-Scan rc.local: error: first parameter is not a valid address family: Transport endpoint is not connected
May 06 20:54:23 Pi-Scan rc.local: error: first parameter is not a valid address family: Transport endpoint is not connected
May 06 20:54:24 Pi-Scan rc.local: error: first parameter is not a valid address family: Transport endpoint is not connected
May 06 20:54:25 Pi-Scan rc.local: error: first parameter is not a valid address family: Transport endpoint is not connected
May 06 20:54:26 Pi-Scan rc.local: error: first parameter is not a valid address family: Transport endpoint is not connected
May 06 20:54:27 Pi-Scan rc.local: error: first parameter is not a valid address family: Transport endpoint is not connected
May 06 20:54:28 Pi-Scan rc.local: error: first parameter is not a valid address family: Transport endpoint is not connected
However if I issue systemctl restart rc-local.service
The program executes a second instance and works fine!
Thinking that this may be a racing condition, I have tried adding a sleep 5 before the command and still get the same problems.
Asked by Nigel W Johnson
(3 rep)
May 7, 2023, 01:11 AM
Last activity: May 7, 2023, 08:07 AM
Last activity: May 7, 2023, 08:07 AM