0

I have a cron every two minutes (*/2 * * * *) firing the following command...

wget "http://www.example.com/wp-cron.php?import_key=my_key_stringimport_id=16&action=trigger"

Trouble is, it is emailing me every two minutes, and also creating copious tiny files on the server, one each time.

I have tried several things. I know there is plenty of info out there about suppressing email feedback from cron.

cPanel's Cron page, where my crons are set, makes clear: "If you do not want an email to be sent for an individual cron job, you can redirect the command’s output to /dev/null. For example: mycommand >/dev/null 2>&1"

But when I did it like this...

wget -O "http://www.example.com/wp-cron.php?import_key=my_key_stringimport_id=16&action=trigger" >/dev/null 2>&1

... the cron stopped functioning.

(I believed an -O was necessarily to direct the output).

What is the proper way to formulate this?

Robert Andrews
  • 1,209
  • 4
  • 23
  • 47

2 Answers2

0

This seems to do the trick...

wget --quiet -O "http://www.example.com/wp-cron.php?import_key=my_key_stringimport_id=16&action=trigger"

Ie. Add --quiet

Answer found elsewhere on Stackoverflow.

Bit confused how --quiet and -O co-exist.

Robert Andrews
  • 1,209
  • 4
  • 23
  • 47
  • There is no problem, `--quiet` and `-O`can coexist. But the command is wrong, after `-O` must be filename – Romeo Ninov Jan 15 '19 at 07:40
  • Oh, yes, that was kind of a typo - I shouldn't have left in `>/dev/null 2>&1` after the file - I have edited my own answer. `http://www.example.com/wp-cron.php?import_key=my_key_stringimport_id=16&action=trigger` is the file to execute. – Robert Andrews Jan 15 '19 at 18:33
0

To suppress mails from cron you can add before your line in cron MAILTO

MAILTO=""
*/2 * * * * command
Romeo Ninov
  • 6,538
  • 1
  • 22
  • 31