setting up rsync cron job, not executing
So I have just setup my new Ubuntu Server 18.04. I have the main primary OS installed on an SSD, the second HDD (primary media drive) mounted to /media and the backup drive mounted to /mnt. I have set both /media and /mnt to be able to be written too without needing sudo permissions.
I wanted to setup a daily rsync backup from /media to /mnt.
So I ran
sudo crontab -e
Then at the bottom of the file I put
0 22 * * * rsync -av --delete /media /mnt
I did this about 1PM yesterday and I think this should have ran at about 10PM. I got up this morning and the cron job did not execute. Any ideas?
This is what the journal shows
Jan 19 21:17:01 grierserver CRON[23622]: pam_unix(cron:session): session closed for user root
Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session opened for user root by (uid=0)
Jan 19 22:17:01 grierserver CRON[26813]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session closed for user root
server cron rsync
add a comment |
So I have just setup my new Ubuntu Server 18.04. I have the main primary OS installed on an SSD, the second HDD (primary media drive) mounted to /media and the backup drive mounted to /mnt. I have set both /media and /mnt to be able to be written too without needing sudo permissions.
I wanted to setup a daily rsync backup from /media to /mnt.
So I ran
sudo crontab -e
Then at the bottom of the file I put
0 22 * * * rsync -av --delete /media /mnt
I did this about 1PM yesterday and I think this should have ran at about 10PM. I got up this morning and the cron job did not execute. Any ideas?
This is what the journal shows
Jan 19 21:17:01 grierserver CRON[23622]: pam_unix(cron:session): session closed for user root
Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session opened for user root by (uid=0)
Jan 19 22:17:01 grierserver CRON[26813]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session closed for user root
server cron rsync
1
Doesjournalctl -u cron.service
shows that thersync
command did execute? You also can add&> /tmp/rsync.log
to your crontab command to log the output (0 22 * * * rsync -av --delete /media /mnt &> /tmp/rsync.log
).
– Thomas
Jan 20 at 14:02
This is what the journal shows "Jan 19 21:17:01 grierserver CRON[23622]: pam_unix(cron:session): session closed for user root Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session opened for user root by (uid=0) Jan 19 22:17:01 grierserver CRON[26813]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session closed for user root " I will add that line to the end.
– DMGrier
Jan 20 at 14:34
You may want to add this to the question by editing the question.?
– Thomas
Jan 20 at 14:37
1
Consider using redirection so you can log all the -v output (and error messages)
– user535733
Jan 20 at 14:41
Incron
the environment is very simple (PATH and other environment variables are not what you have in a text screen or terminal window). Try with full path,/usr/bin/rsync
, it may be enough for it to start working.
– sudodus
Jan 20 at 16:19
add a comment |
So I have just setup my new Ubuntu Server 18.04. I have the main primary OS installed on an SSD, the second HDD (primary media drive) mounted to /media and the backup drive mounted to /mnt. I have set both /media and /mnt to be able to be written too without needing sudo permissions.
I wanted to setup a daily rsync backup from /media to /mnt.
So I ran
sudo crontab -e
Then at the bottom of the file I put
0 22 * * * rsync -av --delete /media /mnt
I did this about 1PM yesterday and I think this should have ran at about 10PM. I got up this morning and the cron job did not execute. Any ideas?
This is what the journal shows
Jan 19 21:17:01 grierserver CRON[23622]: pam_unix(cron:session): session closed for user root
Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session opened for user root by (uid=0)
Jan 19 22:17:01 grierserver CRON[26813]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session closed for user root
server cron rsync
So I have just setup my new Ubuntu Server 18.04. I have the main primary OS installed on an SSD, the second HDD (primary media drive) mounted to /media and the backup drive mounted to /mnt. I have set both /media and /mnt to be able to be written too without needing sudo permissions.
I wanted to setup a daily rsync backup from /media to /mnt.
So I ran
sudo crontab -e
Then at the bottom of the file I put
0 22 * * * rsync -av --delete /media /mnt
I did this about 1PM yesterday and I think this should have ran at about 10PM. I got up this morning and the cron job did not execute. Any ideas?
This is what the journal shows
Jan 19 21:17:01 grierserver CRON[23622]: pam_unix(cron:session): session closed for user root
Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session opened for user root by (uid=0)
Jan 19 22:17:01 grierserver CRON[26813]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session closed for user root
server cron rsync
server cron rsync
edited Jan 20 at 15:23
PerlDuck
6,73711535
6,73711535
asked Jan 20 at 13:46
DMGrierDMGrier
265
265
1
Doesjournalctl -u cron.service
shows that thersync
command did execute? You also can add&> /tmp/rsync.log
to your crontab command to log the output (0 22 * * * rsync -av --delete /media /mnt &> /tmp/rsync.log
).
– Thomas
Jan 20 at 14:02
This is what the journal shows "Jan 19 21:17:01 grierserver CRON[23622]: pam_unix(cron:session): session closed for user root Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session opened for user root by (uid=0) Jan 19 22:17:01 grierserver CRON[26813]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session closed for user root " I will add that line to the end.
– DMGrier
Jan 20 at 14:34
You may want to add this to the question by editing the question.?
– Thomas
Jan 20 at 14:37
1
Consider using redirection so you can log all the -v output (and error messages)
– user535733
Jan 20 at 14:41
Incron
the environment is very simple (PATH and other environment variables are not what you have in a text screen or terminal window). Try with full path,/usr/bin/rsync
, it may be enough for it to start working.
– sudodus
Jan 20 at 16:19
add a comment |
1
Doesjournalctl -u cron.service
shows that thersync
command did execute? You also can add&> /tmp/rsync.log
to your crontab command to log the output (0 22 * * * rsync -av --delete /media /mnt &> /tmp/rsync.log
).
– Thomas
Jan 20 at 14:02
This is what the journal shows "Jan 19 21:17:01 grierserver CRON[23622]: pam_unix(cron:session): session closed for user root Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session opened for user root by (uid=0) Jan 19 22:17:01 grierserver CRON[26813]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session closed for user root " I will add that line to the end.
– DMGrier
Jan 20 at 14:34
You may want to add this to the question by editing the question.?
– Thomas
Jan 20 at 14:37
1
Consider using redirection so you can log all the -v output (and error messages)
– user535733
Jan 20 at 14:41
Incron
the environment is very simple (PATH and other environment variables are not what you have in a text screen or terminal window). Try with full path,/usr/bin/rsync
, it may be enough for it to start working.
– sudodus
Jan 20 at 16:19
1
1
Does
journalctl -u cron.service
shows that the rsync
command did execute? You also can add &> /tmp/rsync.log
to your crontab command to log the output ( 0 22 * * * rsync -av --delete /media /mnt &> /tmp/rsync.log
).– Thomas
Jan 20 at 14:02
Does
journalctl -u cron.service
shows that the rsync
command did execute? You also can add &> /tmp/rsync.log
to your crontab command to log the output ( 0 22 * * * rsync -av --delete /media /mnt &> /tmp/rsync.log
).– Thomas
Jan 20 at 14:02
This is what the journal shows "Jan 19 21:17:01 grierserver CRON[23622]: pam_unix(cron:session): session closed for user root Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session opened for user root by (uid=0) Jan 19 22:17:01 grierserver CRON[26813]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session closed for user root " I will add that line to the end.
– DMGrier
Jan 20 at 14:34
This is what the journal shows "Jan 19 21:17:01 grierserver CRON[23622]: pam_unix(cron:session): session closed for user root Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session opened for user root by (uid=0) Jan 19 22:17:01 grierserver CRON[26813]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session closed for user root " I will add that line to the end.
– DMGrier
Jan 20 at 14:34
You may want to add this to the question by editing the question.?
– Thomas
Jan 20 at 14:37
You may want to add this to the question by editing the question.?
– Thomas
Jan 20 at 14:37
1
1
Consider using redirection so you can log all the -v output (and error messages)
– user535733
Jan 20 at 14:41
Consider using redirection so you can log all the -v output (and error messages)
– user535733
Jan 20 at 14:41
In
cron
the environment is very simple (PATH and other environment variables are not what you have in a text screen or terminal window). Try with full path, /usr/bin/rsync
, it may be enough for it to start working.– sudodus
Jan 20 at 16:19
In
cron
the environment is very simple (PATH and other environment variables are not what you have in a text screen or terminal window). Try with full path, /usr/bin/rsync
, it may be enough for it to start working.– sudodus
Jan 20 at 16:19
add a comment |
2 Answers
2
active
oldest
votes
By doing sudo crontab -e
, you edited root
's crontab
(I guess to ensure your backup executed as root
).
However, root
's crontab
has a field that $USER
crontab
s do not.
root
crontab
specifies the USERID to use in the 6th field, and the rest of the parameters move over.
See man 5 crontab
, the EXAMPLE SYSTEM CRON FILE
section.
You should specify (in root
's `crontab only)
0 22 * * * root rsync -av --delete /media /mnt
^^^^
But, a better way to do it is to wrap the rsync
command in a bash
script (which uses full bash
syntax, is easy to change, test, add debug stuff, ...) and call that script from cron
.
1
What you say is wrong.sudo crontab -e
(=root's crontab) does not have a user field, only/etc/crontab
(=system crontab) has.
– PerlDuck
Jan 21 at 18:30
add a comment |
Okay, so looks like it is working. Doesn't appear to run at 10 but does work. I noticed that by adding this code to the crontab without sudo it works just fine.
Another question I have is when I look in the folder which rsync is syncing too and I run an "ls" command, why do the new file being synced show in purple? Does the color just help me find them or does it mean something?
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1111374%2fsetting-up-rsync-cron-job-not-executing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
By doing sudo crontab -e
, you edited root
's crontab
(I guess to ensure your backup executed as root
).
However, root
's crontab
has a field that $USER
crontab
s do not.
root
crontab
specifies the USERID to use in the 6th field, and the rest of the parameters move over.
See man 5 crontab
, the EXAMPLE SYSTEM CRON FILE
section.
You should specify (in root
's `crontab only)
0 22 * * * root rsync -av --delete /media /mnt
^^^^
But, a better way to do it is to wrap the rsync
command in a bash
script (which uses full bash
syntax, is easy to change, test, add debug stuff, ...) and call that script from cron
.
1
What you say is wrong.sudo crontab -e
(=root's crontab) does not have a user field, only/etc/crontab
(=system crontab) has.
– PerlDuck
Jan 21 at 18:30
add a comment |
By doing sudo crontab -e
, you edited root
's crontab
(I guess to ensure your backup executed as root
).
However, root
's crontab
has a field that $USER
crontab
s do not.
root
crontab
specifies the USERID to use in the 6th field, and the rest of the parameters move over.
See man 5 crontab
, the EXAMPLE SYSTEM CRON FILE
section.
You should specify (in root
's `crontab only)
0 22 * * * root rsync -av --delete /media /mnt
^^^^
But, a better way to do it is to wrap the rsync
command in a bash
script (which uses full bash
syntax, is easy to change, test, add debug stuff, ...) and call that script from cron
.
1
What you say is wrong.sudo crontab -e
(=root's crontab) does not have a user field, only/etc/crontab
(=system crontab) has.
– PerlDuck
Jan 21 at 18:30
add a comment |
By doing sudo crontab -e
, you edited root
's crontab
(I guess to ensure your backup executed as root
).
However, root
's crontab
has a field that $USER
crontab
s do not.
root
crontab
specifies the USERID to use in the 6th field, and the rest of the parameters move over.
See man 5 crontab
, the EXAMPLE SYSTEM CRON FILE
section.
You should specify (in root
's `crontab only)
0 22 * * * root rsync -av --delete /media /mnt
^^^^
But, a better way to do it is to wrap the rsync
command in a bash
script (which uses full bash
syntax, is easy to change, test, add debug stuff, ...) and call that script from cron
.
By doing sudo crontab -e
, you edited root
's crontab
(I guess to ensure your backup executed as root
).
However, root
's crontab
has a field that $USER
crontab
s do not.
root
crontab
specifies the USERID to use in the 6th field, and the rest of the parameters move over.
See man 5 crontab
, the EXAMPLE SYSTEM CRON FILE
section.
You should specify (in root
's `crontab only)
0 22 * * * root rsync -av --delete /media /mnt
^^^^
But, a better way to do it is to wrap the rsync
command in a bash
script (which uses full bash
syntax, is easy to change, test, add debug stuff, ...) and call that script from cron
.
answered Jan 21 at 18:17
waltinatorwaltinator
22.4k74169
22.4k74169
1
What you say is wrong.sudo crontab -e
(=root's crontab) does not have a user field, only/etc/crontab
(=system crontab) has.
– PerlDuck
Jan 21 at 18:30
add a comment |
1
What you say is wrong.sudo crontab -e
(=root's crontab) does not have a user field, only/etc/crontab
(=system crontab) has.
– PerlDuck
Jan 21 at 18:30
1
1
What you say is wrong.
sudo crontab -e
(=root's crontab) does not have a user field, only /etc/crontab
(=system crontab) has.– PerlDuck
Jan 21 at 18:30
What you say is wrong.
sudo crontab -e
(=root's crontab) does not have a user field, only /etc/crontab
(=system crontab) has.– PerlDuck
Jan 21 at 18:30
add a comment |
Okay, so looks like it is working. Doesn't appear to run at 10 but does work. I noticed that by adding this code to the crontab without sudo it works just fine.
Another question I have is when I look in the folder which rsync is syncing too and I run an "ls" command, why do the new file being synced show in purple? Does the color just help me find them or does it mean something?
add a comment |
Okay, so looks like it is working. Doesn't appear to run at 10 but does work. I noticed that by adding this code to the crontab without sudo it works just fine.
Another question I have is when I look in the folder which rsync is syncing too and I run an "ls" command, why do the new file being synced show in purple? Does the color just help me find them or does it mean something?
add a comment |
Okay, so looks like it is working. Doesn't appear to run at 10 but does work. I noticed that by adding this code to the crontab without sudo it works just fine.
Another question I have is when I look in the folder which rsync is syncing too and I run an "ls" command, why do the new file being synced show in purple? Does the color just help me find them or does it mean something?
Okay, so looks like it is working. Doesn't appear to run at 10 but does work. I noticed that by adding this code to the crontab without sudo it works just fine.
Another question I have is when I look in the folder which rsync is syncing too and I run an "ls" command, why do the new file being synced show in purple? Does the color just help me find them or does it mean something?
answered Jan 31 at 0:51
DMGrierDMGrier
265
265
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1111374%2fsetting-up-rsync-cron-job-not-executing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Does
journalctl -u cron.service
shows that thersync
command did execute? You also can add&> /tmp/rsync.log
to your crontab command to log the output (0 22 * * * rsync -av --delete /media /mnt &> /tmp/rsync.log
).– Thomas
Jan 20 at 14:02
This is what the journal shows "Jan 19 21:17:01 grierserver CRON[23622]: pam_unix(cron:session): session closed for user root Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session opened for user root by (uid=0) Jan 19 22:17:01 grierserver CRON[26813]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Jan 19 22:17:01 grierserver CRON[26812]: pam_unix(cron:session): session closed for user root " I will add that line to the end.
– DMGrier
Jan 20 at 14:34
You may want to add this to the question by editing the question.?
– Thomas
Jan 20 at 14:37
1
Consider using redirection so you can log all the -v output (and error messages)
– user535733
Jan 20 at 14:41
In
cron
the environment is very simple (PATH and other environment variables are not what you have in a text screen or terminal window). Try with full path,/usr/bin/rsync
, it may be enough for it to start working.– sudodus
Jan 20 at 16:19