tags:

views:

187

answers:

3

I've got a php script that uses curl and everything is fine. It runs via a cron job. I come back later and each time it runs a new file with the output has been saved.

How do I prevent these files from being created?

+1  A: 

It's the cron daemon that makes that file. By default it saves the stdout into a file. Change the script to point its output to /dev/null instead:

/etc/crontab:

59 *    * * *   USER    curl localhost/script.php > /dev/null 2>&1

That would do the trick.

/Zyber

Zyberzero
jjclarkson
But, the the author of the question said that he used curl to call the script. How ever, if you're using anything else just change curl localhost/script.php to whatever you use.
Zyberzero
A: 

If you're using wget to call your script in cron, you might need to set output to dev/null in the following manner:

59 * * * * wget -O - -q http://yourdomain.com/path/to/script.php

The -O specifies where output is written and the following - specifies dev/null. -q tells wget to run in quiet mode, meaning it won't write messages to stdout.

You can also suppress any output from cron, if it is creating the files, by changing the above line to the following:

59 * * * * wget -O - -q http://yourdomain.com/path/to/script.php > /dev/null 2>&1
Dustin Fineout
A: 

The problem was since this is on a 'shared' hosting account, they claim it's not possible to send the cron results to /dev/null. Who knows, who cares. To fix the issue I've created a script that deletes the output files every day. Thanks for everyone's help.

B2