Php – Cron job creating empty file each time it runs

cronPHP

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.

Best Answer

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.

Related Topic