tags:

views:

173

answers:

1

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.

+3  A: 

When wget runs, by default, it generates an output file, from what I need to remember.

You probably need to use some option of wget, to specify to which file it should write its output -- and use /dev/null as destination file (It's a "special file" that will "eat" everything you can write to it)


Judging from man wget, the -O or --output-file option would be a good candidate :

-O file
--output-document=file
The documents will not be written to the appropriate files, but all will be concatenated together and written to file.

so, you might need to use something like this :

wget -O /dev/null http://www.example.com/your-script.php


And, btw, the output of scripts run from the crontab is often redirected to a logfile -- it can always help.

Something like this might help, about that :

wget -O /dev/null http://www.example.com/your-script.php >> /YOUR_PATH_logfile.log

And you might also want to redirect the error output to another file (can be useful, to help with debugging, the day something goes wrong) :

wget -O /dev/null http://www.example.com/your-script.php >>/YOUR_PATH/log-output.log 2>>/YOUR_PATH/log-errors.log
Pascal MARTIN
Worked perfectly. Thanks for all the information, I appreciate it.
scatteredbomb
You're welcome :-) Glad I could help !
Pascal MARTIN