crontab -e not running @reboot script
Hello, Just installed Ubuntu 14.04 and I'm trying to get crontab to excute a script at reboot that will run in a detached screen. For example, I run a game server and when the power goes off I want the machine to excute the script automatically when it reboots to the login prompt. I have tried crontab -e @reboot path/to/script sudo crontab -e path/to script I put the script in the home dir and did ~/ sh scrptname.sh...Any ideas?
Here's my latest attempt using sudo crontab -e @reboot ~/sh craftbukkit.sh ...that doesn't work I have already tried just a regular crontab -e @reboot /home/steve/craftbukkit.sh ....that doesn't work either, and yes the script is executable. |
If it is a user crontab, it already knows the path to your home directory.
I tend to put Code:
@reboot sh /home/steve/craftbukkit.sh Personally, I've never had a use for the @reboot option (yet). |
does something like this provide anything useful:
Code:
@reboot /bin/echo hello-world > ~/reboot.test Code:
crontab -l |
Quote:
Quote:
Quote:
|
please use code tags. what are trying to run and who are you trying to run it as. i assume you know that preceding a command with sudo will attempt to run it as root ?
Quote:
Code:
/root/sh /craftbukkit.sh |
That was just my latest attempt to try to get it to work, I started out just running it as a regular user crontab and had no success. As I noted in my previous post I have already tried running crontab -e, then typing
Quote:
Quote:
Quote:
|
Maybe this feature has been disabled in the new Ubuntu 14.04 server due to security concerns. I have read post of creating a startup process in init.d and making symbollic links but I'm not that well versed in that sort of thing yet.
If I call the script from the terminal command line it works perfecdtly, I do have the option of logging in automatically and using the startup applications from the GUI but of course that presents security concerns as well. |
does this test create the file:
Code:
@reboot /bin/echo hello-world > ~/reboot.test methinks you have to fill in the paths of the things you are calling. |
No, I'm sorry I forgot to mention that...I'll try it in a regular user crontab and see if it does.....
|
Yep, It made the txt file in my home directory....
Code:
@reboot sh /home/steve/craftbukkit.sh ...but I still have no script running detached :( what if I bash it? that certainly works from the command line... Quote:
|
Ok, first off, does your craftbukkit.sh script need to be run with sudo/root privileges?
If the answer to that is no, then don't put it in sudo/root's crontab, you're just unnecessarily complicating things. If you want to run it as steve, then put it in steve's crontab. Second, why are you running /home/steve/sh in that latest attempt? Do you have an sh executable located in /home/steve? If the answer to that is no (it almost certainly is), then that command will do nothing but throw an error. If you can't run the command you enter, then neither can the cron. I understand you're frustrated, but putting nonsense in the crontab will just waste time and frustrate you even more. Before you put any entry in the cron, you should first do the following: Code:
export PATH=/usr/bin:/bin |
I must of posted the previous thread right when you were typing this one.....
Also the @reboot bash craftbukkit.sh didn't work either. Code:
teve@eodsteven:~$ screen -ls And yes it works perfect from command line... Quote:
|
have you run "mail" to see if you're getting any error messages from the script?
You could also append "> ~/craftbukkit.out 2>&1" to the end of your entry, so it looks like: Code:
@reboot sh /home/steve/craftbukkit.sh > /home/steve/craftbukkit.out 2>&1 |
craftbukkit.out says...
Quote:
so now were back to super user again. |
Yikes this is a bug that has already been reported but its a million years old....
Code:
Cannot make directory '/var/run/screen': Permission denied (convert init to upstart) |
All times are GMT -5. The time now is 02:38 AM. |