Site icon DesignLinux

[Resolved] Cron job wget writing files to root directory

[Resolved] Cron job wget writing files to root directory

Wget is command line utility for downloading files in Linux from web. Using wget utility you can trigger server side scripts using cron job. It also can be used to download files with FPT, HTTP, HTTPS protocols.

Problem

When you use wget with cron job it will save the downloaded files under home directory. So it will create large number of junk files on your system.

Solution

You should use the option -O with wget command to write the result file to specific file and location. After that select /dev/null device file as target file. It will ignore everything written to it. As a result, no junk files will be created in your home directory.

For example, below is the basic wget command:

wget http://releases.ubuntu.com/18.04/ubuntu-18.04.2-desktop-amd64.iso

You should change in above command to:

wget -q -O /dev/null http://releases.ubuntu.com/18.04/ubuntu-18.04.2-desktop-amd64.iso

Here:

That’s it. Now the junk files will not be created anymore.

Conclusion

Hope this tutorial helps you to avoid unwanted files on root generated by wget cron jobs. You can learn more about Wget visit the GNU wget Manual page.

Exit mobile version