Beginner Linux user! Having trouble with cron

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
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?
ubuntu cron
add a comment |Â
up vote
1
down vote
favorite
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?
ubuntu cron
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
Jan 5 at 21:30
1
Is the cron daemon enabled and running? How did you edit your crontab (withcrontab -eor some other method)?
â jayhendren
Jan 5 at 21:31
1
Does your script have execute permissions (i.e. what doesls -l /home/ben/minecraft/Backups/Test.shsay)?
â jayhendren
Jan 5 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
Jan 5 at 21:37
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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?
ubuntu cron
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?
ubuntu cron
edited Jan 5 at 21:41
asked Jan 5 at 21:21
user269086
84
84
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
Jan 5 at 21:30
1
Is the cron daemon enabled and running? How did you edit your crontab (withcrontab -eor some other method)?
â jayhendren
Jan 5 at 21:31
1
Does your script have execute permissions (i.e. what doesls -l /home/ben/minecraft/Backups/Test.shsay)?
â jayhendren
Jan 5 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
Jan 5 at 21:37
add a comment |Â
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
Jan 5 at 21:30
1
Is the cron daemon enabled and running? How did you edit your crontab (withcrontab -eor some other method)?
â jayhendren
Jan 5 at 21:31
1
Does your script have execute permissions (i.e. what doesls -l /home/ben/minecraft/Backups/Test.shsay)?
â jayhendren
Jan 5 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
Jan 5 at 21:37
2
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
Jan 5 at 21:30
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
Jan 5 at 21:30
1
1
Is the cron daemon enabled and running? How did you edit your crontab (with
crontab -e or some other method)?â jayhendren
Jan 5 at 21:31
Is the cron daemon enabled and running? How did you edit your crontab (with
crontab -e or some other method)?â jayhendren
Jan 5 at 21:31
1
1
Does your script have execute permissions (i.e. what does
ls -l /home/ben/minecraft/Backups/Test.sh say)?â jayhendren
Jan 5 at 21:32
Does your script have execute permissions (i.e. what does
ls -l /home/ben/minecraft/Backups/Test.sh say)?â jayhendren
Jan 5 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
Jan 5 at 21:37
@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
Jan 5 at 21:37
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
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
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
Jan 5 at 22:02
Ohhhh. It seems I was making executable the scripts the wrong way... It's necessary to specify the whole path?
â user269086
Jan 5 at 22:13
@user269086 it is not necessary. I used the whole path, since I don't know which is yourpwd... relative paths are ok as well : )
â ncomputers
Jan 5 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
Jan 5 at 23:12
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
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
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
Jan 5 at 22:02
Ohhhh. It seems I was making executable the scripts the wrong way... It's necessary to specify the whole path?
â user269086
Jan 5 at 22:13
@user269086 it is not necessary. I used the whole path, since I don't know which is yourpwd... relative paths are ok as well : )
â ncomputers
Jan 5 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
Jan 5 at 23:12
add a comment |Â
up vote
2
down vote
accepted
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
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
Jan 5 at 22:02
Ohhhh. It seems I was making executable the scripts the wrong way... It's necessary to specify the whole path?
â user269086
Jan 5 at 22:13
@user269086 it is not necessary. I used the whole path, since I don't know which is yourpwd... relative paths are ok as well : )
â ncomputers
Jan 5 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
Jan 5 at 23:12
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
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
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
answered Jan 5 at 21:48
ncomputers
8381418
8381418
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
Jan 5 at 22:02
Ohhhh. It seems I was making executable the scripts the wrong way... It's necessary to specify the whole path?
â user269086
Jan 5 at 22:13
@user269086 it is not necessary. I used the whole path, since I don't know which is yourpwd... relative paths are ok as well : )
â ncomputers
Jan 5 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
Jan 5 at 23:12
add a comment |Â
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
Jan 5 at 22:02
Ohhhh. It seems I was making executable the scripts the wrong way... It's necessary to specify the whole path?
â user269086
Jan 5 at 22:13
@user269086 it is not necessary. I used the whole path, since I don't know which is yourpwd... relative paths are ok as well : )
â ncomputers
Jan 5 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
Jan 5 at 23:12
1
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
Jan 5 at 22:02
Oh my! It... it works! Thank you so much! I had no idea that the change directory thing could be finicky like that.
â user269086
Jan 5 at 22:02
Ohhhh. It seems I was making executable the scripts the wrong way... It's necessary to specify the whole path?
â user269086
Jan 5 at 22:13
Ohhhh. It seems I was making executable the scripts the wrong way... It's necessary to specify the whole path?
â user269086
Jan 5 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
Jan 5 at 22:20
@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
Jan 5 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
Jan 5 at 23:12
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
Jan 5 at 23:12
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f415088%2fbeginner-linux-user-having-trouble-with-cron%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Jan 5 at 21:30
1
Is the cron daemon enabled and running? How did you edit your crontab (with
crontab -eor some other method)?â jayhendren
Jan 5 at 21:31
1
Does your script have execute permissions (i.e. what does
ls -l /home/ben/minecraft/Backups/Test.shsay)?â jayhendren
Jan 5 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
Jan 5 at 21:37