Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

mutt in shell script not working crontab

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
Sophjer
Posts: 7
Joined: 2016-03-27 21:56

mutt in shell script not working crontab

#1 Post by Sophjer »

I've got a shell script that needs to be automated via crontab. I've tested the script by running it manually and it works as intended.
I have also confirmed that the script runs from the crontab entry, but there is one line in the script that doesn't work, where I use mutt to send me a notification.
The script still works but the following command doesn't

Code: Select all

mutt -s "Alert about the website" -a log/$LOGFILE.txt temp/index.html -- myemail@mycompany.ca < message.txt
I've also tried adding the output of

Code: Select all

echo $PATH

Code: Select all

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
to the top of the cron file when I edit it with

Code: Select all

crontab -e
but get:

Code: Select all

errors in crontab file, can't install.
Do you want to retry the same edit? (y/n)
Basically I'm writing a script that will alert me of any changes on one of our sites using curl, diff and mutt.
Thanks

Sophjer
Posts: 7
Joined: 2016-03-27 21:56

Re: mutt in shell script not working crontab

#2 Post by Sophjer »

Thanks wizard10000 that's exactly what I ended up doing.
Now it works.
I thought I had read elsewhere someone explained how to set your path in the crontab entry somehow.
I think I need to teach myself python and I could probably make this thing do the job even better.

Thanks for your help.

User avatar
grumpy_geek
Posts: 22
Joined: 2017-01-20 16:03

Re: mutt in shell script not working crontab

#3 Post by grumpy_geek »

Sophjer wrote:how to set your path in the crontab entry

Code: Select all

# user-level crontab

# be explicit
PATH=/usr/bin
# not required
SHELL=/bin/bash

* * * * * xterm -display :0 -hold -e "echo $PATH; echo $SHELL"

# [ file ends here ]

Sophjer
Posts: 7
Joined: 2016-03-27 21:56

Re: mutt in shell script not working crontab

#4 Post by Sophjer »

Thanks for that, will try soon.
Have now moved onto other wild & crazy projects

Post Reply