Skip to content

Instantly share code, notes, and snippets.

@eib
Last active July 3, 2018 10:17
Show Gist options
  • Save eib/05c5e5464c34d9b08f06 to your computer and use it in GitHub Desktop.
Save eib/05c5e5464c34d9b08f06 to your computer and use it in GitHub Desktop.
How to start a node service (lirc-web) around boot-time on a Raspberry pi
# File: sudo crontab -e
# Starts "lirc-web" 30 seconds after boot: https://github.com/alexbain/lirc_web
@reboot (sleep 30 && /home/pi/scripts/startup/lirc-web.sh) &
#!/bin/bash
# File: /home/pi/scripts/lirc-web.sh
PORT=80 /usr/local/bin/node /home/pi/apps/lirc_web/ > /home/pi/apps/lirc_web/out.log
#!/bin/sh -e
#
# /etc/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.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
# Fix for crontab @reboot not working: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=635473
/etc/init.d/cron/start
exit 0
Goal: To start a node process at boot time on a Raspberry Pi
Solution:
* Add a @reboot line to root's crontab
* Work-around those jobs not starting (as of Raspbian wheezy, I think) via rc.local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment