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

Arriving at the same result with the opposite hypotheses

What was with Miles Morales's stickers?

Why only the fundamental frequency component is said to give useful power?

Implement Homestuck's Catenative Doomsday Dice Cascader

How did they achieve the Gunslinger's shining eye effect in Westworld?

Can anyone identify this tank?

"You've got another thing coming" - translation into French

Trapping Rain Water

How did students remember what to practise between lessons without any sheet music?

What language is the software written in on the ISS?

No array bounds check when using auto

Can an Aarakocra use a shield while flying?

Is using haveibeenpwned to validate password strength rational?

Comparing and find out which feature has highest shape area in QGIS?

How powerful is a "Breathe Air" spell?

Find duplicated column value in CSV

Orange material in grout lines - need help to identify

Does setting a new type clear the rules text for non-lands?

Is open-sourcing the code of a webapp not recommended?

Is the term 'open source' a trademark?

Are there downsides to using std::string as a buffer?

Why would future John risk sending back a T-800 to save his younger self?

How do I write "Show, Don't Tell" as a person with Asperger Syndrome?

Was there a priest on the Titanic who stayed on the ship giving confession to as many as he could?



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;








4















I have added the following crontab job:



sudo crontab -e


enter image description here



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


enter image description here



And when I run:



systemctl status cron


enter image description here



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










share|improve this question



















  • 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

















4















I have added the following crontab job:



sudo crontab -e


enter image description here



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


enter image description here



And when I run:



systemctl status cron


enter image description here



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










share|improve this question



















  • 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













4












4








4








I have added the following crontab job:



sudo crontab -e


enter image description here



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


enter image description here



And when I run:



systemctl status cron


enter image description here



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










share|improve this question
















I have added the following crontab job:



sudo crontab -e


enter image description here



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


enter image description here



And when I run:



systemctl status cron


enter image description here



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 21 at 10:22







Hooman Bahreini

















asked May 21 at 10:17









Hooman BahreiniHooman Bahreini

1747




1747







  • 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












  • 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







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










1 Answer
1






active

oldest

votes


















9















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






share|improve this answer

























  • 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. 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





    +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











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
);



);













draft saved

draft discarded


















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









9















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






share|improve this answer

























  • 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. 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





    +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















9















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






share|improve this answer

























  • 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. 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





    +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













9












9








9








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






share|improve this answer
















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







share|improve this answer














share|improve this answer



share|improve this answer








edited May 21 at 10:47

























answered May 21 at 10:31









vidarlovidarlo

11.6k53054




11.6k53054












  • 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. 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





    +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







  • 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






  • 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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

Esgonzo ibérico Índice Descrición Distribución Hábitat Ameazas Notas Véxase tamén "Acerca dos nomes dos anfibios e réptiles galegos""Chalcides bedriagai"Chalcides bedriagai en Carrascal, L. M. Salvador, A. (Eds). Enciclopedia virtual de los vertebrados españoles. Museo Nacional de Ciencias Naturales, Madrid. España.Fotos