954,242 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Php scripts and crons strange behaviour

So, I have 2-3 php scripts that I run as crons calling them using wget: /usr/bin/wget -o /dev/null http://example.com/cronrss.php
These files (cronrss.php) are getting copied in the example.com directory every time the cron runs, every new file having a new number (/home/example/cronrss.php1, ...cronrss.php2 etc)
So, what could be the reason for this strange behaviour?
I'm not very good with this but I guess the cronjobs are configured properly. They're running once per day, every middle of the night, at minute 0, then 5, then 10 etc.
Thanks!

wattaman
Junior Poster in Training
95 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

wget is intended to download remote files via the command line, so what you're explaining is the expected behavior. The -o option is for logging output, where the -O option is for file output. If you're just wanting to download a file but throw all data away then use something like this:

wget -o /dev/null -O /dev/null - http://www.apexsoftware.com >> /dev/null 2>&1
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

I'm not sure I fully understood your instructions. I just want to run a simple php script. It works when opened in browser, it is removing some old database tables; is working as a cron, too, but I don't want the file copied all the time.
I used the -o /dev/null because I've read it should stop email being sent to owner, therefore save a little resources on the server's side. Am I wrong?
Thanks for trying to help.

wattaman
Junior Poster in Training
95 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

Try swapping out your cron line with the one I provided and see if that does the trick

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

Well, until you try you don't know :)
Your cron line work exactly like I wanted to, silently; no files are being copied now and no emails are being sent to user.
Thank you very much, Sknake!

wattaman
Junior Poster in Training
95 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: