Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was making a cron job to save my Minecraft world from my ram every 5 minutes. I tested the script and it seems to be working.

This is what the script looks like:


rsync -r -t -v "$VOLATILE" "$PERMANENT"

So then I went to add a cron job to run the script every 5 minutes, and it doesn't seem to be running it.

This is the script I used:

*/5 * * * * bash /home/jonathan/Games/Minecraft/Server/

Can anyone help me please?

share|improve this question
cronjobs are run by root, who may have no permission to write on that folders. Does the script work if you run it as root? – jasmines Jul 16 '12 at 12:15
@jasmines I'm having trouble understanding your comment. Root has permissions to write everywhere, while your first sentence states otherwise. – hexafraction Jul 16 '12 at 14:05
You should remove the -v on that rsync command. You don't want verbose output in a cronjob; you want a cronjob to only output anything if something goes wrong. – geirha Jul 16 '12 at 19:00
up vote 5 down vote accepted

You did not specify how you added your cronjob. This makes a big difference: if you've used crontab -e within your own account, scripts are run with your user (and thus the crontab entry has one field less -- the user to run it, as that is known). If you simply copied your above snipped to /etc/cron.d, it would fail as you didn't specify a user (or rather as it finds no user named "bash"). So you should take the following steps:

  1. update your question with information concerning how you added the cron job
  2. check the system logs (/var/log/syslog; they could point to possible errors)
  3. add some debug output to your script to see whether it is started

Third point can be achieved multiple ways:

  • add a >>/tmp/testlog.log to the end of your crontab entry (to redirect output to a file you can investigate; additionally, a 2>&1 would include output from the error console)
  • add some lines to your script itself, like e.g. echo " started">/tmp/testlog.log

Moreover: As you inted your script to be run using bash, you should not tell it using /bin/sh (which would make it using dash on a default Ubuntu installation), but rather /bin/bash. Then make it executable, and you can even ommit the "bash" from your crontab entry.


According to your comment on my anser, you used crontab -e to create the job, and according to your systems logs it is executed, but the definition is rather

*/5 * * * * bash /home/jonathan/Games/Minecraft/Server/ &>/dev/null

This redirects all output to the biggest storage in your system, the "black hole": /dev/null eats everything (but never returns anything). Redirecting STDOUT as well as STDERR this way robs you of any error report -- so you never know that they happened at all, let alone the details. For testing, you should ommit the &>/dev/null part completely. Even if it works, you should only suppress unnecessary output -- as otherwise you never know when something goes wrong. So better leave out the ampersand at least, so Cron can report any occuring errors.

Furthermore: Once the output is redirected (as in your case to /dev/null), appending another redirect to the end will yield no results, as everything is already gone. So I have to adjust above advice from "add ... to the end of your crontab entry" to "replace that in your crontab entry" ;)

share|improve this answer
Thanks for the answer. – user77242 Jul 16 '12 at 15:51
You're welcome. If this solved your problem, you may "accept" it (by clicking once on the checkmark on the left to it). This is a good custom on all StackExchange sites -- and helps others to go straight to the most helpful answer (well, in this case it's only one, I know). Otherwise, if you have further questions, feel free to ask them. – Izzy Jul 16 '12 at 15:56
Sorry i'm new to this site >_> and I kinda messed up my full comment. My full comment is: Thanks for the answer. I used crontab -e to make the crontab. I done what you said and I have no luck at the moment. The Syslog gives me " Jul 16 16:53:01 jonathan-GA-890GPA-UD3H CRON[4568]: (jonathan) CMD (sudo bash /home/jonathan/Games/Minecraft/Server/ &>/dev/null >>/tmp/testlog.log)" every 5 minutes. And the testlog gives me nothing. Any ideas? – user77242 Jul 16 '12 at 15:57
The testlog cannot give you anything this way, as everything is already been eaten up by /dev/null. Change the line in your crontab to bash /home/jonathan/Games/Minecraft/Server/ >>/tmp/testlog.log (i.e. kick off the &>/dev/null part) and try again. -- But what that log entry clearly states is that your job is executed. Which already answers your question ;) Now we just need to figure out why it is not doing what you expect -- and this I hope to see in the testlog. – Izzy Jul 16 '12 at 16:16
The testlog says " finished sending incremental file list ./ level.dat level.dat_old region/r.-1.0.mca region/r.0.0.mca sent 3749210 bytes received 94 bytes 7498608.00 bytes/sec total size is 3748911 speedup is 1.00" Seems to say what it says when I run the script manually. – user77242 Jul 16 '12 at 17:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.