Avoid files are being created when cron is executed
Some times we might have noticed that there are large number of tiny files are created on the home directory with the name of the cron file. For example if your cron url is https://www.hostingahead.com/cron your home directory will have files like cron.1, cron.2 etc..
A typical cron command will be like this :
This has two problems. 1) This download the file and save to disk also the notification may be emailed to the user as well. In order to avoid we modify it as below
wget -O https://hostingahead.com/cron > /dev/null 2>&1
More info:
> is for redirect
/dev/null is a black hole where any data sent, will be discarded
2 is the file descriptor for Standard Error
> is for redirect
& is the symbol for file descriptor (without it, the following 1 would be considered a filename)
1 is the file descriptor for Standard Out
Therefore >/dev/null 2>&1 is redirect the output of your program to /dev/null. Include both the Standard Error and Standard Out.