0

I have a couple of Python scripts I want to launch at bootup. One is located at the path below. /home/my-sickbeard-install/SickBeard.py Since Cron has never ever worked for me and nobody on about 5 forums knows how to fix my Cron problem even though it's a pretty much clean install of the OS, I need another method of launching these scripts on bootup. Can someone suggest to me another way I can launch them please? Note: This is actually for something I'm trying to do a Debian machine. Not sure if it makes any difference.

john smith
  • 3,033
  • How is this any form of way a possible duplicate jacob? My question very clearly states about a problem with crontab and how to not use crontab to do this function. That link goes straight onto an answer of "use crontab". Wish I could vote-down your statement. – john smith Jun 28 '15 at 15:08
  • @karel, that answer also does not provide the answer to my question as I do not wish to run my program as root. So both your statements are wrong and I get a downvote because you both clearly don't understand my goal. – john smith Jun 28 '15 at 15:12

2 Answers2

0

You can add it to /etc/rc.local. This can be used to run scripts and programs on system boot which doesn't have their own scripts for runlevels. It will run as root

Run sudo nano /etc/rc.local and add your line before exit 0

#!/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.

python /home/my-sickbeard-install/SickBeard.py 2>&1 >/dev/null &

exit 0

Press CTRL+ O to save and CTRL+ X to exit.

Germar
  • 6,377
  • 2
  • 26
  • 39
  • What is the rc local file, and what does it do? – john smith Jun 28 '15 at 12:47
  • @johnsmith I updated my answer. My previous attempt doesn't work because /etc/rc.local must end with exit 0 – Germar Jun 28 '15 at 13:04
  • Hi this does work, however when I reboot now, it won't shutdown because it says "A stop job is running for /etc/rc.local Compatibility (1min 9s/ no limit)". It's effectively just broke my server. – john smith Jun 28 '15 at 14:57
  • @johnsmith okay, so this is a long running task. You need to send it into background with 2>&1 >/dev/null &. I updated the answer. – Germar Jun 28 '15 at 15:01
  • Thanks I spotted it. However I just tried it again using the bit of config you put in & the problem still is there. – john smith Jun 28 '15 at 15:02
  • You should make sure your script does exit on SIGTERM like if you kill PID the process. Otherwise your system will wait and send SIGKILL after a timeout on shutdown. – Germar Jun 29 '15 at 01:28
0

have you tryed this:

python-py | echo '/home/my-sickbeard-install/SickBeard.py'
cron -l /home/my-sickbeard-install/SickBeard.py
cron -l -restart

and it might work fine this way.

Michael
  • 2,499
  • 5
  • 19
  • 24
  • cron always says "no crontab for [user]". Nobody knows how to fix it. I won't use cron. If you think you can fix it, please see http://unix.stackexchange.com/questions/212703/crontab-error-no-crontab-for-user – john smith Jun 28 '15 at 12:47
  • it is only cron not crontab – Michael Jun 28 '15 at 14:13
  • Ok I didn't realise there was a difference. I just tried typing $cron -l and it gives an error, bash: cron command not found. It seems that cron or crontab just never work for me. – john smith Jun 28 '15 at 15:06