0

i tried to google but had no luck perhaps because i am not sure on the terms to look for. basically im trying to auto run a screen after the system reboots. i tried crontab but it seems that i cannot execute the jar file unless im in the directory.

something like crontab -e:

@reboot screen -d -m -S ModBot java -jar /home/themoduser/modbotfiles/ModBot.jar  start

im not sure if that is a correct method or if trying to use a .sh script:

cd /home/themoduser/modbotfiles/
screen -d -m -S ts3bot java -jar ModBot.jar

and in crontab

@reboot /home/themoduser/modbotfiles/ModBot_startscript.sh start
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
droopie
  • 441
  • 3
  • 12
  • You can do `cd /somewhere && screen --etc` to `cd` before running `screen`, but making a script file is preferable. – that other guy Feb 06 '15 at 19:05
  • how would the script file look like? – droopie Feb 06 '15 at 19:22
  • Basically just like you posted it. Just add a `#!/bin/sh` and chmod +x the file. – that other guy Feb 06 '15 at 20:41
  • Make sure the command works outside of crontab first, then go through [the crontab info page](http://stackoverflow.com/tags/crontab/info) to troubleshoot it in crontab. – that other guy Feb 06 '15 at 21:09
  • Once you make sure it works without crontab, you can temporarily create a crontab entry that runs the command just once (say, 34 13 * * * screen ...` to run it at 1:34pm), so you don't have to reboot the system to test it. – Keith Thompson Feb 06 '15 at 21:42
  • the .sh script method works when i run it manually but does not run on startup with crontab – droopie Feb 06 '15 at 22:44

0 Answers0