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;








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









New contributor



Hooman Bahreini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 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









New contributor



Hooman Bahreini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 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









New contributor



Hooman Bahreini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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









New contributor



Hooman Bahreini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



Hooman Bahreini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited May 21 at 10:22







Hooman Bahreini













New contributor



Hooman Bahreini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked May 21 at 10:17









Hooman BahreiniHooman Bahreini

1747




1747




New contributor



Hooman Bahreini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Hooman Bahreini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









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



);






Hooman Bahreini is a new contributor. Be nice, and check out our Code of Conduct.









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










Hooman Bahreini is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















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.




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

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?