Crontab mail issue

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have python script which sends email by shell function "mail". It runs fine. However, when I put in crontab to run it is unable to send mail to the recipient, rather it sends error message to my address. Is there any issue that crontab cannot send mail running via another script?



Here is my crontab entry:




30 8 * * * /home/akand/./pyscript.py




The pyscript.py has



import os 
os.system(''' mail -s "Message" ...@gmail.com <<< "Please
check ..." ''')


As I mentioned, pyscript.py runs fine.







share|improve this question


















  • 1




    Please edit your question to include the crontab entry that you are using.
    – Kusalananda
    Apr 10 at 15:11










  • Although I have edited tags, it doesn't show, at least not from my end.
    – Akand
    Apr 10 at 15:38










  • You have an issue with your cron job and to see what the issue is, we would need to see what your crontab entry looks like. Please add the output of crontab -l (or just the specific entry) into the text of the question.
    – Kusalananda
    Apr 10 at 15:40






  • 1




    What's the error message? Is it an empty body or recipient? You may have an interactive environment variable that's not being set by cron.
    – Jeff Schaller
    Apr 10 at 16:09










  • In dead.letter following is produced: To: found, not, command, line....@gmail.com Subject: Message: ...... User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit
    – Akand
    Apr 10 at 16:40















up vote
0
down vote

favorite












I have python script which sends email by shell function "mail". It runs fine. However, when I put in crontab to run it is unable to send mail to the recipient, rather it sends error message to my address. Is there any issue that crontab cannot send mail running via another script?



Here is my crontab entry:




30 8 * * * /home/akand/./pyscript.py




The pyscript.py has



import os 
os.system(''' mail -s "Message" ...@gmail.com <<< "Please
check ..." ''')


As I mentioned, pyscript.py runs fine.







share|improve this question


















  • 1




    Please edit your question to include the crontab entry that you are using.
    – Kusalananda
    Apr 10 at 15:11










  • Although I have edited tags, it doesn't show, at least not from my end.
    – Akand
    Apr 10 at 15:38










  • You have an issue with your cron job and to see what the issue is, we would need to see what your crontab entry looks like. Please add the output of crontab -l (or just the specific entry) into the text of the question.
    – Kusalananda
    Apr 10 at 15:40






  • 1




    What's the error message? Is it an empty body or recipient? You may have an interactive environment variable that's not being set by cron.
    – Jeff Schaller
    Apr 10 at 16:09










  • In dead.letter following is produced: To: found, not, command, line....@gmail.com Subject: Message: ...... User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit
    – Akand
    Apr 10 at 16:40













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have python script which sends email by shell function "mail". It runs fine. However, when I put in crontab to run it is unable to send mail to the recipient, rather it sends error message to my address. Is there any issue that crontab cannot send mail running via another script?



Here is my crontab entry:




30 8 * * * /home/akand/./pyscript.py




The pyscript.py has



import os 
os.system(''' mail -s "Message" ...@gmail.com <<< "Please
check ..." ''')


As I mentioned, pyscript.py runs fine.







share|improve this question














I have python script which sends email by shell function "mail". It runs fine. However, when I put in crontab to run it is unable to send mail to the recipient, rather it sends error message to my address. Is there any issue that crontab cannot send mail running via another script?



Here is my crontab entry:




30 8 * * * /home/akand/./pyscript.py




The pyscript.py has



import os 
os.system(''' mail -s "Message" ...@gmail.com <<< "Please
check ..." ''')


As I mentioned, pyscript.py runs fine.









share|improve this question













share|improve this question




share|improve this question








edited Apr 11 at 15:33









Debian_yadav

8342522




8342522










asked Apr 10 at 15:09









Akand

426




426







  • 1




    Please edit your question to include the crontab entry that you are using.
    – Kusalananda
    Apr 10 at 15:11










  • Although I have edited tags, it doesn't show, at least not from my end.
    – Akand
    Apr 10 at 15:38










  • You have an issue with your cron job and to see what the issue is, we would need to see what your crontab entry looks like. Please add the output of crontab -l (or just the specific entry) into the text of the question.
    – Kusalananda
    Apr 10 at 15:40






  • 1




    What's the error message? Is it an empty body or recipient? You may have an interactive environment variable that's not being set by cron.
    – Jeff Schaller
    Apr 10 at 16:09










  • In dead.letter following is produced: To: found, not, command, line....@gmail.com Subject: Message: ...... User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit
    – Akand
    Apr 10 at 16:40













  • 1




    Please edit your question to include the crontab entry that you are using.
    – Kusalananda
    Apr 10 at 15:11










  • Although I have edited tags, it doesn't show, at least not from my end.
    – Akand
    Apr 10 at 15:38










  • You have an issue with your cron job and to see what the issue is, we would need to see what your crontab entry looks like. Please add the output of crontab -l (or just the specific entry) into the text of the question.
    – Kusalananda
    Apr 10 at 15:40






  • 1




    What's the error message? Is it an empty body or recipient? You may have an interactive environment variable that's not being set by cron.
    – Jeff Schaller
    Apr 10 at 16:09










  • In dead.letter following is produced: To: found, not, command, line....@gmail.com Subject: Message: ...... User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit
    – Akand
    Apr 10 at 16:40








1




1




Please edit your question to include the crontab entry that you are using.
– Kusalananda
Apr 10 at 15:11




Please edit your question to include the crontab entry that you are using.
– Kusalananda
Apr 10 at 15:11












Although I have edited tags, it doesn't show, at least not from my end.
– Akand
Apr 10 at 15:38




Although I have edited tags, it doesn't show, at least not from my end.
– Akand
Apr 10 at 15:38












You have an issue with your cron job and to see what the issue is, we would need to see what your crontab entry looks like. Please add the output of crontab -l (or just the specific entry) into the text of the question.
– Kusalananda
Apr 10 at 15:40




You have an issue with your cron job and to see what the issue is, we would need to see what your crontab entry looks like. Please add the output of crontab -l (or just the specific entry) into the text of the question.
– Kusalananda
Apr 10 at 15:40




1




1




What's the error message? Is it an empty body or recipient? You may have an interactive environment variable that's not being set by cron.
– Jeff Schaller
Apr 10 at 16:09




What's the error message? Is it an empty body or recipient? You may have an interactive environment variable that's not being set by cron.
– Jeff Schaller
Apr 10 at 16:09












In dead.letter following is produced: To: found, not, command, line....@gmail.com Subject: Message: ...... User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit
– Akand
Apr 10 at 16:40





In dead.letter following is produced: To: found, not, command, line....@gmail.com Subject: Message: ...... User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit
– Akand
Apr 10 at 16:40











1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










As Jeff mentioned, the environment variable was not passing. The command in crontab:



30 8 * * * $HOME/.bash_profile; /home/akand/./pyscript.py 


worked.






share|improve this answer






















  • I would have understood that it would work with . "$HOME/.bash_profile", but as you have written it now, it just runs .bash_profile as a script. That means that the environment variables are not passed on to the Python script.
    – Kusalananda
    Apr 11 at 15:26










  • If I understand well, the pyscript.py is in my home directory, that's the reason I do not need to specify <. "$HOME/.bash_profile" >
    – Akand
    Apr 11 at 15:37











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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436798%2fcrontab-mail-issue%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










As Jeff mentioned, the environment variable was not passing. The command in crontab:



30 8 * * * $HOME/.bash_profile; /home/akand/./pyscript.py 


worked.






share|improve this answer






















  • I would have understood that it would work with . "$HOME/.bash_profile", but as you have written it now, it just runs .bash_profile as a script. That means that the environment variables are not passed on to the Python script.
    – Kusalananda
    Apr 11 at 15:26










  • If I understand well, the pyscript.py is in my home directory, that's the reason I do not need to specify <. "$HOME/.bash_profile" >
    – Akand
    Apr 11 at 15:37















up vote
0
down vote



accepted










As Jeff mentioned, the environment variable was not passing. The command in crontab:



30 8 * * * $HOME/.bash_profile; /home/akand/./pyscript.py 


worked.






share|improve this answer






















  • I would have understood that it would work with . "$HOME/.bash_profile", but as you have written it now, it just runs .bash_profile as a script. That means that the environment variables are not passed on to the Python script.
    – Kusalananda
    Apr 11 at 15:26










  • If I understand well, the pyscript.py is in my home directory, that's the reason I do not need to specify <. "$HOME/.bash_profile" >
    – Akand
    Apr 11 at 15:37













up vote
0
down vote



accepted







up vote
0
down vote



accepted






As Jeff mentioned, the environment variable was not passing. The command in crontab:



30 8 * * * $HOME/.bash_profile; /home/akand/./pyscript.py 


worked.






share|improve this answer














As Jeff mentioned, the environment variable was not passing. The command in crontab:



30 8 * * * $HOME/.bash_profile; /home/akand/./pyscript.py 


worked.







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 11 at 15:24









Kusalananda

102k13200317




102k13200317










answered Apr 11 at 15:22









Akand

426




426











  • I would have understood that it would work with . "$HOME/.bash_profile", but as you have written it now, it just runs .bash_profile as a script. That means that the environment variables are not passed on to the Python script.
    – Kusalananda
    Apr 11 at 15:26










  • If I understand well, the pyscript.py is in my home directory, that's the reason I do not need to specify <. "$HOME/.bash_profile" >
    – Akand
    Apr 11 at 15:37

















  • I would have understood that it would work with . "$HOME/.bash_profile", but as you have written it now, it just runs .bash_profile as a script. That means that the environment variables are not passed on to the Python script.
    – Kusalananda
    Apr 11 at 15:26










  • If I understand well, the pyscript.py is in my home directory, that's the reason I do not need to specify <. "$HOME/.bash_profile" >
    – Akand
    Apr 11 at 15:37
















I would have understood that it would work with . "$HOME/.bash_profile", but as you have written it now, it just runs .bash_profile as a script. That means that the environment variables are not passed on to the Python script.
– Kusalananda
Apr 11 at 15:26




I would have understood that it would work with . "$HOME/.bash_profile", but as you have written it now, it just runs .bash_profile as a script. That means that the environment variables are not passed on to the Python script.
– Kusalananda
Apr 11 at 15:26












If I understand well, the pyscript.py is in my home directory, that's the reason I do not need to specify <. "$HOME/.bash_profile" >
– Akand
Apr 11 at 15:37





If I understand well, the pyscript.py is in my home directory, that's the reason I do not need to specify <. "$HOME/.bash_profile" >
– Akand
Apr 11 at 15:37













 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436798%2fcrontab-mail-issue%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?