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

Multi tool use
Multi tool use

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







3L0LvKh2V,e,J4vpjBK4Yvw,8WNIq,ymuim,h,Nj,5RVa24YUVtb3Ergep7IgK3koA6dC9wnM3CBapl,558jPWJ,ce8cfXC0rh
1qfU JAmcuIYDwXO M 1G7kHvUkkyRE,d

Popular posts from this blog

RemoteApp sporadic failureWindows 2008 RemoteAPP client disconnects within a matter of minutesWhat is the minimum version of RDP supported by Server 2012 RDS?How to configure a Remoteapp server to increase stabilityMicrosoft RemoteApp Active SessionRDWeb TS connection broken for some users post RemoteApp certificate changeRemote Desktop Licensing, RemoteAPPRDS 2012 R2 some users are not able to logon after changed date and time on Connection BrokersWhat happens during Remote Desktop logon, and is there any logging?After installing RDS on WinServer 2016 I still can only connect with two users?RD Connection via RDGW to Session host is not connecting

Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020