Cron job creating empty file each time it runs

I have a php script I want to run every minute to see if there are draft news posts that need to be posted. I was using "wget" for the cron command in cPanel, but i noticed (after a couple days) that this was creating a blank file in the main directory every single time it ran. Is there something I need to stop that from happening?

Thanks.


Solution 1:

You need to send the output of that wget command to /dev/null if you want to avoid creating a file of the (blank) response from your php script.

Example in curl

curl -q http://your.server/script.php > /dev/null

Example in wget

wget -q -O /dev/null http://your.server/script.php

If you have the choice, you should use curl, that is a better tool for this job.

Solution 2:

Without seeing your script, or the filename or the crontab entry it's hard to guess, but this is what I'd look at first. Try adding one or both of -o /dev/null and/or -O /dev/null to the parameters of your wget call. The first one sends stderr to the bit bucket and the second one sends the files that wget would download there. You can also use the -q switch to turn off other output. Your choice of these depends on how you're using wget.