Score:0

Can't find Cron mail and cron jobs dont work

rs flag

I have 2 scripts in crontab -e:

0 0 */3 * * /bin/bash /home/user/scripts/3day-san-backup.sh >> /var/log/3day-san-backup.log2>&1

0 0 */1 * * /bin/bash /home/user/scripts/1day-pny-backup.sh >> /var/log/1day-pny-backup.log 2>&1

They dont work, so I check cron logs. Also, the custom log files I made are empty.

Jun 21 08:09:01 goofy-server CRON[55054]: (user) CMD (/bin/bash /home/user/scripts/1day-pny-backup.sh >> /var/log/1day-pny-backup.log 2>&1)
Jun 21 08:09:01 goofy-server CRON[55052]: (user) MAIL (mailed 74 bytes of output but got status 0x004b from MTA#012)

So the mail doesn't work so I try to download something:

I ran sudo apt-get install postfix, then cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf, then I added inet_interfaces = loopback-only in the new file. I just want to setup the mail system locally so I can read the cron logs. But when I type mail, it just says Cannot open mailbox /var/mail/user: No such file or directory. I do have /var/spool/mail though, but that directory is empty. Though, when I check the cron logs again, I don't get that error that says something about the mail. Where is the mail, and why are my custom logs empty?

Raffa avatar
jp flag
You need to change `/var/log/3day-san-backup.log2>&1` to `/var/log/3day-san-backup.log 2>&1` ... Does your user have write permissions to those log files? ... Are your scripts executable?
hr flag
The log entry `... got status 0x004b from MTA#012` suggests there was already some type of mail transfer agent running before you installed postfix (otherwise you'd get `No MTA installed, discarding output` I think?)
raj avatar
cn flag
raj
`mail` program wants to use file `/var/mail/username` by default as mail storage, and it doesn't exist. If Postfix delivered mail correctly (check in `/var/log/mail.log`), then it may be configured to deliver mail to different location (probably `/home/username/Maildir`). Check parameters `home_mailbox` and `mail_spool_directory` in your `/etc/postfix/main.cf` file. The first one should be empty (or not present at all), and the second one should be `/var/mail` for mail delivery compatible with `mail` program.
spirledaxis avatar
rs flag
@raj, I did not have either of those parameters in my `/etc/postfix/main.cf` file, but I added the ``mail_spool_directory`` to it.
raj avatar
cn flag
raj
And does it work with `mail_spool_directory` added? (remember to restart Postfix after changing `main.cf`)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.