shell script is not executed after adding it as a crontab jobWhy does my bash script output “+ '[' 0 -le 1 ']'” when started with bash -x script.sh?crontab command not runroot cron job not runningWhy the cron job did not fire on ubuntu 12.04?Why my cron Job does not work?Help, ubuntu server 14.04 crontab cannot run my database backup script, but other simple script is okCrontab script not runningRoot cron job not executing script properly. PATH or HOME directories the problem?Cron Script Not WorkingCron job,crontabsome crontab job not working , not all
When and what was the first 3D acceleration device ever released?
Seed ship, unsexed person, cover has golden person attached to ship by umbilical cord
I unknowingly submitted plagiarised work
Why is this Simple Puzzle impossible to solve?
Employer demanding to see degree after poor code review
When do characters level up?
What is the object moving across the ceiling in this stock footage?
Integrating an absolute function using Mathematica
Are there situations when self-assignment is useful?
Where is the logic in castrating fighters?
Would Brexit have gone ahead by now if Gina Miller had not forced the Government to involve Parliament?
Why do airplanes use an axial flow jet engine instead of a more compact centrifugal jet engine?
How can people dance around bonfires on Lag Lo'Omer - it's darchei emori?
Crossing US border with music files I'm legally allowed to possess
What are these arcade games in Ghostbusters 1984?
Python program to convert a 24 hour format to 12 hour format
Windows 10 Programs start without visual Interface
Plot twist where the antagonist wins
Is floating in space similar to falling under gravity?
What is the difference between nullifying your vote and not going to vote at all?
How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?
How long does it take to crack RSA 1024 with a PC?
How do you say “buy” in the sense of “believe”?
How do I subvert the tropes of a train heist?
shell script is not executed after adding it as a crontab job
Why does my bash script output “+ '[' 0 -le 1 ']'” when started with bash -x script.sh?crontab command not runroot cron job not runningWhy the cron job did not fire on ubuntu 12.04?Why my cron Job does not work?Help, ubuntu server 14.04 crontab cannot run my database backup script, but other simple script is okCrontab script not runningRoot cron job not executing script properly. PATH or HOME directories the problem?Cron Script Not WorkingCron job,crontabsome crontab job not working , not all
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have added the following crontab job:
sudo crontab -e
58 * * * * ubuntu /home/ubuntu/backup/mysqlbackup.sh
>/home/ubuntu/backup/log/backup.log
I have tried both root and ubuntu users.
When I run the command:
sudo crontab -l
And when I run:
systemctl status cron
But mysqlbackup.sh is not executed. Any idea what is the problem or how can I diagnose what is going wrong?
Note I have added only minutes to test the script
command-line bash cron
New contributor
add a comment |
I have added the following crontab job:
sudo crontab -e
58 * * * * ubuntu /home/ubuntu/backup/mysqlbackup.sh
>/home/ubuntu/backup/log/backup.log
I have tried both root and ubuntu users.
When I run the command:
sudo crontab -l
And when I run:
systemctl status cron
But mysqlbackup.sh is not executed. Any idea what is the problem or how can I diagnose what is going wrong?
Note I have added only minutes to test the script
command-line bash cron
New contributor
2
Add at end of line:2>&1
This will also redirect stderr to same log file. Then check log for errors.
– LeonidMew
May 21 at 10:24
1
To see error messages you can usejournalctl -b | grep -i cron
– WinEunuuchs2Unix
May 21 at 10:37
1
Please don't add screen dumps of text. Copy and paste text and format it corretly.
– Soren A
May 21 at 10:49
@soren, ok thanks for letting me know.
– Hooman Bahreini
May 21 at 10:50
add a comment |
I have added the following crontab job:
sudo crontab -e
58 * * * * ubuntu /home/ubuntu/backup/mysqlbackup.sh
>/home/ubuntu/backup/log/backup.log
I have tried both root and ubuntu users.
When I run the command:
sudo crontab -l
And when I run:
systemctl status cron
But mysqlbackup.sh is not executed. Any idea what is the problem or how can I diagnose what is going wrong?
Note I have added only minutes to test the script
command-line bash cron
New contributor
I have added the following crontab job:
sudo crontab -e
58 * * * * ubuntu /home/ubuntu/backup/mysqlbackup.sh
>/home/ubuntu/backup/log/backup.log
I have tried both root and ubuntu users.
When I run the command:
sudo crontab -l
And when I run:
systemctl status cron
But mysqlbackup.sh is not executed. Any idea what is the problem or how can I diagnose what is going wrong?
Note I have added only minutes to test the script
command-line bash cron
command-line bash cron
New contributor
New contributor
edited May 21 at 10:22
Hooman Bahreini
New contributor
asked May 21 at 10:17
Hooman BahreiniHooman Bahreini
1747
1747
New contributor
New contributor
2
Add at end of line:2>&1
This will also redirect stderr to same log file. Then check log for errors.
– LeonidMew
May 21 at 10:24
1
To see error messages you can usejournalctl -b | grep -i cron
– WinEunuuchs2Unix
May 21 at 10:37
1
Please don't add screen dumps of text. Copy and paste text and format it corretly.
– Soren A
May 21 at 10:49
@soren, ok thanks for letting me know.
– Hooman Bahreini
May 21 at 10:50
add a comment |
2
Add at end of line:2>&1
This will also redirect stderr to same log file. Then check log for errors.
– LeonidMew
May 21 at 10:24
1
To see error messages you can usejournalctl -b | grep -i cron
– WinEunuuchs2Unix
May 21 at 10:37
1
Please don't add screen dumps of text. Copy and paste text and format it corretly.
– Soren A
May 21 at 10:49
@soren, ok thanks for letting me know.
– Hooman Bahreini
May 21 at 10:50
2
2
Add at end of line:
2>&1
This will also redirect stderr to same log file. Then check log for errors.– LeonidMew
May 21 at 10:24
Add at end of line:
2>&1
This will also redirect stderr to same log file. Then check log for errors.– LeonidMew
May 21 at 10:24
1
1
To see error messages you can use
journalctl -b | grep -i cron
– WinEunuuchs2Unix
May 21 at 10:37
To see error messages you can use
journalctl -b | grep -i cron
– WinEunuuchs2Unix
May 21 at 10:37
1
1
Please don't add screen dumps of text. Copy and paste text and format it corretly.
– Soren A
May 21 at 10:49
Please don't add screen dumps of text. Copy and paste text and format it corretly.
– Soren A
May 21 at 10:49
@soren, ok thanks for letting me know.
– Hooman Bahreini
May 21 at 10:50
@soren, ok thanks for letting me know.
– Hooman Bahreini
May 21 at 10:50
add a comment |
1 Answer
1
active
oldest
votes
58 * * * * ubuntu /home/ubuntu/backup/mysqlbackup.sh >/home/ubuntu/backup/log/backup.log
This is incorrect format.
The format is described in the crontab file:
# m h dom mon dow command
ubuntu
is not a command. Remove it, so the line reads:
58 * * * * /home/ubuntu/backup/mysqlbackup.sh >/home/ubuntu/backup/log/backup.log
Systemwide crontab, specified in /etc/crontab
has the user field:
These files also have username fields,
# that none of the other crontabs do.
[...]
# m h dom mon dow user command
Thanks... should I not add the user?
– Hooman Bahreini
May 21 at 10:34
2
No, if you want to run it as a specific user, you should add it to that users crontab, e.g. runcrontab -e
as the user in question. The editor shows you the correct format, complete with examples.
– vidarlo
May 21 at 10:35
4
+1 the user field is an extra field that is only used in system-wide crontabs (/etc/crontab
and files in/etc/cron.d/
)
– steeldriver
May 21 at 10:40
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
);
);
Hooman Bahreini is a new contributor. Be nice, and check out our Code of Conduct.
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%2f1145001%2fshell-script-is-not-executed-after-adding-it-as-a-crontab-job%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
58 * * * * ubuntu /home/ubuntu/backup/mysqlbackup.sh >/home/ubuntu/backup/log/backup.log
This is incorrect format.
The format is described in the crontab file:
# m h dom mon dow command
ubuntu
is not a command. Remove it, so the line reads:
58 * * * * /home/ubuntu/backup/mysqlbackup.sh >/home/ubuntu/backup/log/backup.log
Systemwide crontab, specified in /etc/crontab
has the user field:
These files also have username fields,
# that none of the other crontabs do.
[...]
# m h dom mon dow user command
Thanks... should I not add the user?
– Hooman Bahreini
May 21 at 10:34
2
No, if you want to run it as a specific user, you should add it to that users crontab, e.g. runcrontab -e
as the user in question. The editor shows you the correct format, complete with examples.
– vidarlo
May 21 at 10:35
4
+1 the user field is an extra field that is only used in system-wide crontabs (/etc/crontab
and files in/etc/cron.d/
)
– steeldriver
May 21 at 10:40
add a comment |
58 * * * * ubuntu /home/ubuntu/backup/mysqlbackup.sh >/home/ubuntu/backup/log/backup.log
This is incorrect format.
The format is described in the crontab file:
# m h dom mon dow command
ubuntu
is not a command. Remove it, so the line reads:
58 * * * * /home/ubuntu/backup/mysqlbackup.sh >/home/ubuntu/backup/log/backup.log
Systemwide crontab, specified in /etc/crontab
has the user field:
These files also have username fields,
# that none of the other crontabs do.
[...]
# m h dom mon dow user command
Thanks... should I not add the user?
– Hooman Bahreini
May 21 at 10:34
2
No, if you want to run it as a specific user, you should add it to that users crontab, e.g. runcrontab -e
as the user in question. The editor shows you the correct format, complete with examples.
– vidarlo
May 21 at 10:35
4
+1 the user field is an extra field that is only used in system-wide crontabs (/etc/crontab
and files in/etc/cron.d/
)
– steeldriver
May 21 at 10:40
add a comment |
58 * * * * ubuntu /home/ubuntu/backup/mysqlbackup.sh >/home/ubuntu/backup/log/backup.log
This is incorrect format.
The format is described in the crontab file:
# m h dom mon dow command
ubuntu
is not a command. Remove it, so the line reads:
58 * * * * /home/ubuntu/backup/mysqlbackup.sh >/home/ubuntu/backup/log/backup.log
Systemwide crontab, specified in /etc/crontab
has the user field:
These files also have username fields,
# that none of the other crontabs do.
[...]
# m h dom mon dow user command
58 * * * * ubuntu /home/ubuntu/backup/mysqlbackup.sh >/home/ubuntu/backup/log/backup.log
This is incorrect format.
The format is described in the crontab file:
# m h dom mon dow command
ubuntu
is not a command. Remove it, so the line reads:
58 * * * * /home/ubuntu/backup/mysqlbackup.sh >/home/ubuntu/backup/log/backup.log
Systemwide crontab, specified in /etc/crontab
has the user field:
These files also have username fields,
# that none of the other crontabs do.
[...]
# m h dom mon dow user command
edited May 21 at 10:47
answered May 21 at 10:31
vidarlovidarlo
11.5k53054
11.5k53054
Thanks... should I not add the user?
– Hooman Bahreini
May 21 at 10:34
2
No, if you want to run it as a specific user, you should add it to that users crontab, e.g. runcrontab -e
as the user in question. The editor shows you the correct format, complete with examples.
– vidarlo
May 21 at 10:35
4
+1 the user field is an extra field that is only used in system-wide crontabs (/etc/crontab
and files in/etc/cron.d/
)
– steeldriver
May 21 at 10:40
add a comment |
Thanks... should I not add the user?
– Hooman Bahreini
May 21 at 10:34
2
No, if you want to run it as a specific user, you should add it to that users crontab, e.g. runcrontab -e
as the user in question. The editor shows you the correct format, complete with examples.
– vidarlo
May 21 at 10:35
4
+1 the user field is an extra field that is only used in system-wide crontabs (/etc/crontab
and files in/etc/cron.d/
)
– steeldriver
May 21 at 10:40
Thanks... should I not add the user?
– Hooman Bahreini
May 21 at 10:34
Thanks... should I not add the user?
– Hooman Bahreini
May 21 at 10:34
2
2
No, if you want to run it as a specific user, you should add it to that users crontab, e.g. run
crontab -e
as the user in question. The editor shows you the correct format, complete with examples.– vidarlo
May 21 at 10:35
No, if you want to run it as a specific user, you should add it to that users crontab, e.g. run
crontab -e
as the user in question. The editor shows you the correct format, complete with examples.– vidarlo
May 21 at 10:35
4
4
+1 the user field is an extra field that is only used in system-wide crontabs (
/etc/crontab
and files in /etc/cron.d/
)– steeldriver
May 21 at 10:40
+1 the user field is an extra field that is only used in system-wide crontabs (
/etc/crontab
and files in /etc/cron.d/
)– steeldriver
May 21 at 10:40
add a comment |
Hooman Bahreini is a new contributor. Be nice, and check out our Code of Conduct.
Hooman Bahreini is a new contributor. Be nice, and check out our Code of Conduct.
Hooman Bahreini is a new contributor. Be nice, and check out our Code of Conduct.
Hooman Bahreini is a new contributor. Be nice, and check out our Code of Conduct.
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%2f1145001%2fshell-script-is-not-executed-after-adding-it-as-a-crontab-job%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
2
Add at end of line:
2>&1
This will also redirect stderr to same log file. Then check log for errors.– LeonidMew
May 21 at 10:24
1
To see error messages you can use
journalctl -b | grep -i cron
– WinEunuuchs2Unix
May 21 at 10:37
1
Please don't add screen dumps of text. Copy and paste text and format it corretly.
– Soren A
May 21 at 10:49
@soren, ok thanks for letting me know.
– Hooman Bahreini
May 21 at 10:50