Cronjob help please

This is used for general discussion that is not necessarily server-related.
Post Reply
j0rd0n420
This is my homepage
This is my homepage
Posts: 157
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Mon Jul 07, 2008 1:47 pm

Cronjob help please

Post by j0rd0n420 »

What would I put in crontab -e if I wanted it to run a script in /home/jordon/minecraft every day at 10am and 10pm central time. Thanks all!
User avatar
Edge100x
Founder
Founder
Posts: 13129
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Cronjob help please

Post by Edge100x »

0 10/20 * * * /home/jordon/minecraft/yourscript
j0rd0n420
This is my homepage
This is my homepage
Posts: 157
Joined: Mon Jul 07, 2008 1:47 pm

Re: Cronjob help please

Post by j0rd0n420 »

Thanks, and if I had one to run every hour? (world backup script)
User avatar
Edge100x
Founder
Founder
Posts: 13129
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Cronjob help please

Post by Edge100x »

0 * * * * /home/jordon/minecraft/yourscript

Wikipedia has a pretty good treatment of how crontabs work here: http://en.wikipedia.org/wiki/Cron
j0rd0n420
This is my homepage
This is my homepage
Posts: 157
Joined: Mon Jul 07, 2008 1:47 pm

Re: Cronjob help please

Post by j0rd0n420 »

For some reason the server isn't up when I wake up. It's like its running the script but doesn't bring it back up. But I don't think that's it because just running it myself works fine.

Code: Select all

#!/bin/bash

/usr/bin/screen -x minecraft -X -p0 stuff "`printf "say Server is
restarting in 60 seconds\r"`"
/bin/sleep 29
/usr/bin/screen -x minecraft -X -p0 stuff "`printf "say Server is
restarting in 30 seconds\r"`"
/bin/sleep 24
/usr/bin/screen -x minecraft -X -p0 stuff "`printf "say Server is
restarting in 5 seconds\r"`"
/bin/sleep 1
/usr/bin/screen -x minecraft -X -p0 stuff "`printf "say Server is
restarting in 4 seconds\r"`"
/bin/sleep 1
/usr/bin/screen -x minecraft -X -p0 stuff "`printf "say Server is
restarting in 3 seconds\r"`"
/bin/sleep 1
/usr/bin/screen -x minecraft -X -p0 stuff "`printf "say Server is
restarting in 2 seconds\r"`"
/bin/sleep 1
/usr/bin/screen -x minecraft -X -p0 stuff "`printf "say Server is
restarting in 1 seconds\r"`"
/bin/sleep 1
/usr/bin/screen -x minecraft -X -p0 stuff "`printf "stop\r"`"
/bin/sleep 10
/usr/bin/screen -fa -d -m -S minecraft /usr/bin/java -server -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ParallelGCThreads=2
-Xnoclassgc -Xmx2816M -Xms2816M -jar Minecraft_Mod.jar nogui
Any ideas on why it's never up in the morning? I'm running Ubuntu 10.04 with Bukkit and one plugin.
User avatar
Edge100x
Founder
Founder
Posts: 13129
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Cronjob help please

Post by Edge100x »

It looks like you need to add to your script a "cd" at the beginning to change to the directory of your Minecraft installation.
j0rd0n420
This is my homepage
This is my homepage
Posts: 157
Joined: Mon Jul 07, 2008 1:47 pm

Re: Cronjob help please

Post by j0rd0n420 »

so like this

Code: Select all

cd minecraft
the rest of the script
j0rd0n420
This is my homepage
This is my homepage
Posts: 157
Joined: Mon Jul 07, 2008 1:47 pm

Re: Cronjob help please

Post by j0rd0n420 »

after the bin/bash of course
User avatar
Edge100x
Founder
Founder
Posts: 13129
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Cronjob help please

Post by Edge100x »

Yes, but you should probably make it absolute. "cd /minecraft" or whatever the full path is to your Minecraft folder.
j0rd0n420
This is my homepage
This is my homepage
Posts: 157
Joined: Mon Jul 07, 2008 1:47 pm

Re: Cronjob help please

Post by j0rd0n420 »

Adding the cd /path/to/script/location seems to have fixed it, thanks!
Post Reply