I have some cron tasks, and some of them doesn't stop sending me emails.

An example task are:

*/2 * * * * php app/console mautic:email:fetch > /dev/null 2>&1

(All the tasks with the problem are mautic tasks).

I've tried some tricks for avoiding emails:

> /dev/null
>/dev/null 2>&1
>/dev/null 2>&1 || true
|| true

All of them continues to send mails each run.

An example email:

/bin/sh: 1: cannot create 1: Permission denied

(I understand that's a strange error, but it's a example. I know I need to solve the error and not silence it, but I want to know why I cannot silence it with a normal method).

The question are: Why even when I redirecting the task result, or when using the || true to change the task result, cron continues sending emails? The only solution I can find (on the linked question), are to add


after the "normal" (or not-spamming) cron tasks (and before these other ones).

Related question:How do I completely silence a cronjob to /dev/null/?.

  • How are you editing the crontab (what command do you use, or which file do you edit)? Commented Jan 27, 2019 at 10:03
  • 1
    crontab -u <user> -e. And I opening it with nano. Commented Jan 27, 2019 at 11:37

1 Answer 1


The /bin/sh: 1: cannot create 1: Permission denied error is probably because you have a typo in a redirection. Perhaps instead of 2>&1 you have 2>1 or 2>1&. (Normally the attempt to create a file named 1 in your home directory would succeed, but if a file named 1 already exists and is not writable then you'll get that error.)

The reason why that error isn't silenced is that the message is not coming from the command whose output has been redirected. The message is being reported by the shell during the time it is trying to set up redirection for the command. Output from the shell itself has not been redirected, so the message is collected by cron and emailed to you.

  • I have at least 5 cron lines with the same syntax ( >/dev/null 2>&1) with different error messages each one. Also, these error message are a example, they appears when I didn't have the 2>&1). That's not the problem. The problem are on the app itself. Commented Jan 27, 2019 at 11:36
  • I can't say anything about error messages you haven't shown us. What happens if you cd into your home directory, run /bin/sh, and then run one of the bad commands by copy+pasting it from the crontab? Do you see the error message? (If you're doing this in some other user's crontab then su - <user> and cd to that user's homedir before pasting and running the command. Of course in that case the other user would be getting the emails.) Commented Jan 27, 2019 at 21:37
  • You're right with the answer but I have some commands ok and anothers bad. The error are 2&>1 instead of 2>&1. Thanks. Commented Jan 28, 2019 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .