How to debug cronjob is not trigger in Linux Ubuntu?
Clash Royale CLAN TAG#URR8PPP
I'm in Ubuntu linux.
I just added this cron-job to run every minutes
MAILTO="email@gmail.com"
* * * * * cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py
If I run this command
cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py
It works fine.
I never see it run or get an email.
I ran a mail
command
I got
└── mail
"/var/mail/root": 3 messages 3 new
>N 1 Cron Daemon Sun Oct 15 06:34 21/930 Cron <root@bheng> test -x /usr/sbin/anacron || ( cd / && run
N 2 long@bheng Sun Oct 15 14:19 15/649 *** SECURITY information for bheng ***
N 3 long@bheng Sun Oct 15 14:19 15/649 *** SECURITY information for bheng ***
?
It seems to have issues, how do I fix it ?
Did I forgot something or missing something?
linux cron
|
show 1 more comment
I'm in Ubuntu linux.
I just added this cron-job to run every minutes
MAILTO="email@gmail.com"
* * * * * cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py
If I run this command
cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py
It works fine.
I never see it run or get an email.
I ran a mail
command
I got
└── mail
"/var/mail/root": 3 messages 3 new
>N 1 Cron Daemon Sun Oct 15 06:34 21/930 Cron <root@bheng> test -x /usr/sbin/anacron || ( cd / && run
N 2 long@bheng Sun Oct 15 14:19 15/649 *** SECURITY information for bheng ***
N 3 long@bheng Sun Oct 15 14:19 15/649 *** SECURITY information for bheng ***
?
It seems to have issues, how do I fix it ?
Did I forgot something or missing something?
linux cron
I find it easier to wrap the commands in abash
script and tellcron
to run the script. Easier control, debugging,bash
command interpreter rather thancron
's.
– waltinator
Dec 21 '18 at 2:16
to exclude path issues, it is generally recommended to use full paths in cronjobs. I'd start by using/usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead and see if it works
– AnonymousLurker
Dec 21 '18 at 5:17
I don't see why there should be acd
; use/usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead.
– Vlastimil
Dec 21 '18 at 7:00
I trust you checked your gmail spam folder as well, just in case the message went there?
– derobert
Dec 21 '18 at 9:02
1
If you change the line to* * * * * cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py >/tmp/out 2>/tmp/errs
, do you see anything in either of those files in /tmp after waiting for a minute?
– Mark Plotnick
Dec 21 '18 at 23:53
|
show 1 more comment
I'm in Ubuntu linux.
I just added this cron-job to run every minutes
MAILTO="email@gmail.com"
* * * * * cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py
If I run this command
cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py
It works fine.
I never see it run or get an email.
I ran a mail
command
I got
└── mail
"/var/mail/root": 3 messages 3 new
>N 1 Cron Daemon Sun Oct 15 06:34 21/930 Cron <root@bheng> test -x /usr/sbin/anacron || ( cd / && run
N 2 long@bheng Sun Oct 15 14:19 15/649 *** SECURITY information for bheng ***
N 3 long@bheng Sun Oct 15 14:19 15/649 *** SECURITY information for bheng ***
?
It seems to have issues, how do I fix it ?
Did I forgot something or missing something?
linux cron
I'm in Ubuntu linux.
I just added this cron-job to run every minutes
MAILTO="email@gmail.com"
* * * * * cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py
If I run this command
cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py
It works fine.
I never see it run or get an email.
I ran a mail
command
I got
└── mail
"/var/mail/root": 3 messages 3 new
>N 1 Cron Daemon Sun Oct 15 06:34 21/930 Cron <root@bheng> test -x /usr/sbin/anacron || ( cd / && run
N 2 long@bheng Sun Oct 15 14:19 15/649 *** SECURITY information for bheng ***
N 3 long@bheng Sun Oct 15 14:19 15/649 *** SECURITY information for bheng ***
?
It seems to have issues, how do I fix it ?
Did I forgot something or missing something?
linux cron
linux cron
edited Dec 22 '18 at 6:09
Vlastimil
7,7111260134
7,7111260134
asked Dec 21 '18 at 1:02
kyo
151110
151110
I find it easier to wrap the commands in abash
script and tellcron
to run the script. Easier control, debugging,bash
command interpreter rather thancron
's.
– waltinator
Dec 21 '18 at 2:16
to exclude path issues, it is generally recommended to use full paths in cronjobs. I'd start by using/usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead and see if it works
– AnonymousLurker
Dec 21 '18 at 5:17
I don't see why there should be acd
; use/usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead.
– Vlastimil
Dec 21 '18 at 7:00
I trust you checked your gmail spam folder as well, just in case the message went there?
– derobert
Dec 21 '18 at 9:02
1
If you change the line to* * * * * cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py >/tmp/out 2>/tmp/errs
, do you see anything in either of those files in /tmp after waiting for a minute?
– Mark Plotnick
Dec 21 '18 at 23:53
|
show 1 more comment
I find it easier to wrap the commands in abash
script and tellcron
to run the script. Easier control, debugging,bash
command interpreter rather thancron
's.
– waltinator
Dec 21 '18 at 2:16
to exclude path issues, it is generally recommended to use full paths in cronjobs. I'd start by using/usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead and see if it works
– AnonymousLurker
Dec 21 '18 at 5:17
I don't see why there should be acd
; use/usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead.
– Vlastimil
Dec 21 '18 at 7:00
I trust you checked your gmail spam folder as well, just in case the message went there?
– derobert
Dec 21 '18 at 9:02
1
If you change the line to* * * * * cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py >/tmp/out 2>/tmp/errs
, do you see anything in either of those files in /tmp after waiting for a minute?
– Mark Plotnick
Dec 21 '18 at 23:53
I find it easier to wrap the commands in a
bash
script and tell cron
to run the script. Easier control, debugging, bash
command interpreter rather than cron
's.– waltinator
Dec 21 '18 at 2:16
I find it easier to wrap the commands in a
bash
script and tell cron
to run the script. Easier control, debugging, bash
command interpreter rather than cron
's.– waltinator
Dec 21 '18 at 2:16
to exclude path issues, it is generally recommended to use full paths in cronjobs. I'd start by using
/usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead and see if it works– AnonymousLurker
Dec 21 '18 at 5:17
to exclude path issues, it is generally recommended to use full paths in cronjobs. I'd start by using
/usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead and see if it works– AnonymousLurker
Dec 21 '18 at 5:17
I don't see why there should be a
cd
; use /usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead.– Vlastimil
Dec 21 '18 at 7:00
I don't see why there should be a
cd
; use /usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead.– Vlastimil
Dec 21 '18 at 7:00
I trust you checked your gmail spam folder as well, just in case the message went there?
– derobert
Dec 21 '18 at 9:02
I trust you checked your gmail spam folder as well, just in case the message went there?
– derobert
Dec 21 '18 at 9:02
1
1
If you change the line to
* * * * * cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py >/tmp/out 2>/tmp/errs
, do you see anything in either of those files in /tmp after waiting for a minute?– Mark Plotnick
Dec 21 '18 at 23:53
If you change the line to
* * * * * cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py >/tmp/out 2>/tmp/errs
, do you see anything in either of those files in /tmp after waiting for a minute?– Mark Plotnick
Dec 21 '18 at 23:53
|
show 1 more comment
3 Answers
3
active
oldest
votes
If a cron job fails for some reason, you will get a relevant message through mail. Type 'mail' and check the messages.
When I type mail, I got this : i.imgur.com/NrahSbq.png
– kyo
Dec 21 '18 at 14:42
Is that what you mean ? Do I need to install that mail plug in ?
– kyo
Dec 21 '18 at 14:43
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
add a comment |
As an alternative to mail, consider wrapping your commands into a bash script and then using a log file:
For example, you could create a script /home/forge/scraper.bash with the following contents:
#!/bin/bash -x
cd /home/forge/bheng/public/code/scraper/
/usr/bin/python3 main.py
Give the script execute permissions (chmod +x scraper.bash
), and then set up the cron as follows:
* * * * * /home/forge/scraper.bash &>> /home/forge/scraper.log
The execution output (and errors) should now be available in the /home/forge/scraper.log file. Note that the output is appended to the log file each time the job is run.
add a comment |
The MAILTO
setting in a crontab
file is not generally for Internet email delivery, but rather for local user account delivery, e. g. root
or someuser
.
Am I missing something that why my cron is not running ?
– kyo
Dec 21 '18 at 1:20
I think it should work find... as long as email is fully configured on the system. Which it may well not be (it often can't be by default), that'd be a good thing to explain in your answer.
– derobert
Dec 21 '18 at 9:02
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f490244%2fhow-to-debug-cronjob-is-not-trigger-in-linux-ubuntu%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
If a cron job fails for some reason, you will get a relevant message through mail. Type 'mail' and check the messages.
When I type mail, I got this : i.imgur.com/NrahSbq.png
– kyo
Dec 21 '18 at 14:42
Is that what you mean ? Do I need to install that mail plug in ?
– kyo
Dec 21 '18 at 14:43
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
add a comment |
If a cron job fails for some reason, you will get a relevant message through mail. Type 'mail' and check the messages.
When I type mail, I got this : i.imgur.com/NrahSbq.png
– kyo
Dec 21 '18 at 14:42
Is that what you mean ? Do I need to install that mail plug in ?
– kyo
Dec 21 '18 at 14:43
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
add a comment |
If a cron job fails for some reason, you will get a relevant message through mail. Type 'mail' and check the messages.
If a cron job fails for some reason, you will get a relevant message through mail. Type 'mail' and check the messages.
answered Dec 21 '18 at 2:11
drgnfr
394
394
When I type mail, I got this : i.imgur.com/NrahSbq.png
– kyo
Dec 21 '18 at 14:42
Is that what you mean ? Do I need to install that mail plug in ?
– kyo
Dec 21 '18 at 14:43
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
add a comment |
When I type mail, I got this : i.imgur.com/NrahSbq.png
– kyo
Dec 21 '18 at 14:42
Is that what you mean ? Do I need to install that mail plug in ?
– kyo
Dec 21 '18 at 14:43
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
When I type mail, I got this : i.imgur.com/NrahSbq.png
– kyo
Dec 21 '18 at 14:42
When I type mail, I got this : i.imgur.com/NrahSbq.png
– kyo
Dec 21 '18 at 14:42
Is that what you mean ? Do I need to install that mail plug in ?
– kyo
Dec 21 '18 at 14:43
Is that what you mean ? Do I need to install that mail plug in ?
– kyo
Dec 21 '18 at 14:43
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
add a comment |
As an alternative to mail, consider wrapping your commands into a bash script and then using a log file:
For example, you could create a script /home/forge/scraper.bash with the following contents:
#!/bin/bash -x
cd /home/forge/bheng/public/code/scraper/
/usr/bin/python3 main.py
Give the script execute permissions (chmod +x scraper.bash
), and then set up the cron as follows:
* * * * * /home/forge/scraper.bash &>> /home/forge/scraper.log
The execution output (and errors) should now be available in the /home/forge/scraper.log file. Note that the output is appended to the log file each time the job is run.
add a comment |
As an alternative to mail, consider wrapping your commands into a bash script and then using a log file:
For example, you could create a script /home/forge/scraper.bash with the following contents:
#!/bin/bash -x
cd /home/forge/bheng/public/code/scraper/
/usr/bin/python3 main.py
Give the script execute permissions (chmod +x scraper.bash
), and then set up the cron as follows:
* * * * * /home/forge/scraper.bash &>> /home/forge/scraper.log
The execution output (and errors) should now be available in the /home/forge/scraper.log file. Note that the output is appended to the log file each time the job is run.
add a comment |
As an alternative to mail, consider wrapping your commands into a bash script and then using a log file:
For example, you could create a script /home/forge/scraper.bash with the following contents:
#!/bin/bash -x
cd /home/forge/bheng/public/code/scraper/
/usr/bin/python3 main.py
Give the script execute permissions (chmod +x scraper.bash
), and then set up the cron as follows:
* * * * * /home/forge/scraper.bash &>> /home/forge/scraper.log
The execution output (and errors) should now be available in the /home/forge/scraper.log file. Note that the output is appended to the log file each time the job is run.
As an alternative to mail, consider wrapping your commands into a bash script and then using a log file:
For example, you could create a script /home/forge/scraper.bash with the following contents:
#!/bin/bash -x
cd /home/forge/bheng/public/code/scraper/
/usr/bin/python3 main.py
Give the script execute permissions (chmod +x scraper.bash
), and then set up the cron as follows:
* * * * * /home/forge/scraper.bash &>> /home/forge/scraper.log
The execution output (and errors) should now be available in the /home/forge/scraper.log file. Note that the output is appended to the log file each time the job is run.
answered Dec 21 '18 at 6:37
Haxiel
1,199310
1,199310
add a comment |
add a comment |
The MAILTO
setting in a crontab
file is not generally for Internet email delivery, but rather for local user account delivery, e. g. root
or someuser
.
Am I missing something that why my cron is not running ?
– kyo
Dec 21 '18 at 1:20
I think it should work find... as long as email is fully configured on the system. Which it may well not be (it often can't be by default), that'd be a good thing to explain in your answer.
– derobert
Dec 21 '18 at 9:02
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
add a comment |
The MAILTO
setting in a crontab
file is not generally for Internet email delivery, but rather for local user account delivery, e. g. root
or someuser
.
Am I missing something that why my cron is not running ?
– kyo
Dec 21 '18 at 1:20
I think it should work find... as long as email is fully configured on the system. Which it may well not be (it often can't be by default), that'd be a good thing to explain in your answer.
– derobert
Dec 21 '18 at 9:02
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
add a comment |
The MAILTO
setting in a crontab
file is not generally for Internet email delivery, but rather for local user account delivery, e. g. root
or someuser
.
The MAILTO
setting in a crontab
file is not generally for Internet email delivery, but rather for local user account delivery, e. g. root
or someuser
.
answered Dec 21 '18 at 1:19
DopeGhoti
43.3k55382
43.3k55382
Am I missing something that why my cron is not running ?
– kyo
Dec 21 '18 at 1:20
I think it should work find... as long as email is fully configured on the system. Which it may well not be (it often can't be by default), that'd be a good thing to explain in your answer.
– derobert
Dec 21 '18 at 9:02
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
add a comment |
Am I missing something that why my cron is not running ?
– kyo
Dec 21 '18 at 1:20
I think it should work find... as long as email is fully configured on the system. Which it may well not be (it often can't be by default), that'd be a good thing to explain in your answer.
– derobert
Dec 21 '18 at 9:02
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
Am I missing something that why my cron is not running ?
– kyo
Dec 21 '18 at 1:20
Am I missing something that why my cron is not running ?
– kyo
Dec 21 '18 at 1:20
I think it should work find... as long as email is fully configured on the system. Which it may well not be (it often can't be by default), that'd be a good thing to explain in your answer.
– derobert
Dec 21 '18 at 9:02
I think it should work find... as long as email is fully configured on the system. Which it may well not be (it often can't be by default), that'd be a good thing to explain in your answer.
– derobert
Dec 21 '18 at 9:02
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
Do you have any other suggestions ?
– kyo
Dec 21 '18 at 18:39
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2funix.stackexchange.com%2fquestions%2f490244%2fhow-to-debug-cronjob-is-not-trigger-in-linux-ubuntu%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
I find it easier to wrap the commands in a
bash
script and tellcron
to run the script. Easier control, debugging,bash
command interpreter rather thancron
's.– waltinator
Dec 21 '18 at 2:16
to exclude path issues, it is generally recommended to use full paths in cronjobs. I'd start by using
/usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead and see if it works– AnonymousLurker
Dec 21 '18 at 5:17
I don't see why there should be a
cd
; use/usr/bin/python3 /home/forge/bheng/public/code/scraper/main.py
instead.– Vlastimil
Dec 21 '18 at 7:00
I trust you checked your gmail spam folder as well, just in case the message went there?
– derobert
Dec 21 '18 at 9:02
1
If you change the line to
* * * * * cd /home/forge/bheng/public/code/scraper/; /usr/bin/python3 main.py >/tmp/out 2>/tmp/errs
, do you see anything in either of those files in /tmp after waiting for a minute?– Mark Plotnick
Dec 21 '18 at 23:53