1

I have an Intel NUC with Ubuntu installed. It runs a Minecraft server. I wanted a simple backup system for the server, and through some Googling I found that I can do so using cron and tar. However, I seem to be unable to make cron do anything at all.

I made a simple test script for cron to run.

#!/bin/bash cd ~/minecraft/Backups touch bla.txt

And I modified my crontab by adding this.

# m h dom mon dow command 10 16 * * * /home/ben/minecraft/Backups/Test.sh

I waited for 16:10 to come and... nothing happened. There was no bla.txt file created. I tried it numerous times by entering different times and still nothing.

The script works when I run it manually. Any idea what I'm missing?

4
  • 2
    Please don't post screenshots of text. Instead copy-paste or transcribe the text. Text within images cannot be read by screenreaders (which visually-impaired users might use) nor will Google or other search engines process text within images.
    – jayhendren
    Commented Jan 5, 2018 at 21:30
  • 1
    Is the cron daemon enabled and running? How did you edit your crontab (with crontab -e or some other method)?
    – jayhendren
    Commented Jan 5, 2018 at 21:31
  • 1
    Does your script have execute permissions (i.e. what does ls -l /home/ben/minecraft/Backups/Test.sh say)?
    – jayhendren
    Commented Jan 5, 2018 at 21:32
  • @jayhendren Oh, I didn't realize that screenshots could be problematic. I'll change it shortly. When I run the command you suggested I get: -rwxr-xr-x 1 root root 51 Jan 5 11:37 /home/ben/minecraft/Backups/Test.sh
    – user269086
    Commented Jan 5, 2018 at 21:37

1 Answer 1

2

I am not sure if this answers your question, but I would suggest you to replace this line:

cd ~/minecraft/Backups

With this:

cd /home/ben/minecraft/Backups

Make sure your script has execution permissions:

chmod +x /home/ben/minecraft/Backups/Test.sh

Check if cron is installed and running:

/etc/init.d/cron status

If not, install it / start it:

apt-get install cron
/etc/init.d/cron start
4
  • 1
    Oh my! It... it works! Thank you so much! I had no idea that the change directory thing could be finicky like that.
    – user269086
    Commented Jan 5, 2018 at 22:02
  • Ohhhh. It seems I was making executable the scripts the wrong way... It's necessary to specify the whole path?
    – user269086
    Commented Jan 5, 2018 at 22:13
  • @user269086 it is not necessary. I used the whole path, since I don't know which is your pwd ... relative paths are ok as well : )
    – ncomputers
    Commented Jan 5, 2018 at 22:20
  • Weird. Just now I made executable the backup script again. (My original goal) But this time I specified the entire path. And cron ran the script this time. Well, whatever works.
    – user269086
    Commented Jan 5, 2018 at 23:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .