I have a script which sends emails. It works perfectly when run manually but I doesn't work when run with crontab:
#!/bin/bash
cat $HOME/myfolder/mailbody | /bin/mailx -v -s "mymail" -a file.txt [email protected] > $HOME/myfolder/script.log
When run with crontab, nothing is written in "$HOME/myfolder/script.log". I can't understand why with crontab the command to send the email is not run.
I solved it by specifying the absolute path to mailx attachment argument: