[SOLVED] Cron job wget writing files to root directory

Channel: Linux
Abstract: -q Turn off wget command output -O /dev/null Write downloaded content (file) to /dev/null device. That’s it. Hope this tutorial helps you to avoid unw

The wget command is a command line utility for downloading files from the remote servers. It’s also used to triggers server side scripts using the cron jobs.

Problem

While using the wget with cron job saved the downloaded files under home directory. Due to this a large number of junk files get created in your system.

Solution

Use -O option with wget command to write the result file (data) to specific file and location. Next select /dev/null device file as target file. This will discard anything written to it. In result, no junk files will be created in your home directory.

For example, the original cron job command is:

wget https://www.example.com/cron.php

Update above command to:

 wget -q -O /dev/null https://www.example.com/cron.php

Here:

  • -q Turn off wget command output
  • -O /dev/null Write downloaded content (file) to /dev/null device.

That’s it. Hope this tutorial helps you to avoid unwanted files on root generated by wget cron jobs.

Ref From: tecadmin

Related articles