Instead of adding
cd ~/app && python serve.py in /etc/rc.local, try putting in the entire path. You are expecting the init process to know that ~ is your home directory somehow, but init starts as root. Because init starts as root, it's looking in
/ for the app directory not your home directory. Get rid of the ~ by using the path to your home directory.
pwd to find your pathway directory.) Get rid of the
python in front of your serve.py script by adding
#!/usr/bin/python at the top of your script. (type a
which python to find the path in case it isn't installed in the normal place)
Edit: You did say "run in the background", and I missed that. To run a command in the background, add a
& after the command. So, to background that command above:
/home/whitecolor/app/serve.py & Init doesn't usually need the background symbol to start a job and run it in the background.
DrDR's excellent suggestion would not need the same
& treatment after the command in the cron startup as those are run in the background by default.