I'm trying to get a shell script to start running at boot. It's a basic while loop that copies files into a directory then sleeps for 30 seconds. It starts and runs fine when I start the service myself, but it never seems to be running after bootup.
My sync.sh script
#!/bin/sh
syncdirectory="$HOME/syncdirectory"
targetdirectory="$HOME/targetdirectory"
while :
do
cp -a $syncdirectory/* $targetdirectory
sleep 30
done
My init.d service file
#!/bin/sh /etc/rc.common
START=95
USE_PROCD=1
start_service() {
procd_open_instance
procd_set_param command sh $HOME/sync.sh
procd_set_param respawn # respawn the service if it exits
procd_close_instance
}
In my install script I'm running
cp $HOME/sync /etc/init.d/
chmod +x /etc/init.d/sync
chmod +x $HOME/sync.sh
/etc/init.d/sync enable
/etc/init.d/sync start
Any input would be greatly appreciated as I've been struggling with this for too long. I've even tried starting it in rc.local but that doesn't seem to be working either.
I've also tried not using PROCD. Runs fine if I manually start it, but never on boot.
#!/bin/sh /etc/rc.common
START=95
start() {
sh $HOME/sync.sh &
}