command line cron temporary file cleanup

Status
Not open for further replies.

erect

New member
Jun 3, 2007
3,795
154
0
Esoterica
twitter.com
So I've got this pesky problem that's pissing me off.

I noticed the other day that one of my sites actually saved a temp file in some obscure folder every time it's ran. I'm not too worried about that one because it's out of the way and the files are tiny.

Last week I threw up a new site on a new server that required a script to run every minute, so I set it up. I logged into FTP today and the root folder is loaded up with all these temporary files. the file looks like file_name.php.####

Every minute of every day the folder gets another file and it's starting to piss me off. I can call it remotely from another server wget http:....... and that sidestep the problem but I'd rather address the problem and gain some knowledge in the process.

As far as skills go, I'm barely mediocre at command line hacking ... my questions are

1. Is there a flag to turn off the creation of these temporary files? I'd rather not save them if I have a choice. Something like

* * * * * wget hxxp://www.mysite.com/my_cron.php -no_output

would be an ideal solution

2. when trying to clean up I can use rm and a regex to match the file names since they're all the same file with .#### appended to the end. However, it return an error when trying to delete all the file_name.php.1### because there are too many of them. It will allow me to delete all of file_name.php.11## but then I'd have to click "y" and enter 100 times for each one .... and then doing it for the other 99 numbers (12##, 13##, ...). This is a lot of wasted time.

I've spoken with both google and my support desk and both have surprisingly been less than helpful, though responsive.
 


1) I'd have to know what kind of file it is, like is it a known script, like maybe smarty cache etc? Cuz If I knew what it was, then I could tell you if there was a known setting such as turning off the cache.

2) rm -f ?
 
In your unix command prompt enter (I think): man crontab

That's the crontab manual and it should give you all your options.
 
Code:
* * * * * wget -O /dev/null hxxp://www.mysite.com/my_cron.php &> /dev/null

Will send the output of the wget and the cron email to /dev/null
 
  • Like
Reactions: erect
1) I'd have to know what kind of file it is, like is it a known script, like maybe smarty cache etc?

it's just a custom scrape + mysql update ran 24/7

Code:
* * * * * wget -O /dev/null hxxp://www.mysite.com/my_cron.php &> /dev/null
Will send the output of the wget and the cron email to /dev/null

I use:

wget -O - Google > /dev/null 2>&1

You guys fucking rock, I used the audax code verbatim but it seems like both would do exactly what I'm looking for.

+ rep sent to lenny & audax has some coming but my rep threshold has been reached for the day.
 
Status
Not open for further replies.