Forum Moderators: coopster

Message Too Old, No Replies

Something is truncating my files

         

mbabuskov

10:59 am on Mar 8, 2011 (gmt 0)

10+ Year Member



Hi,

I have a website form that allows users to subscribe to a newsletter. I wrote a sample PHP script that uses fopen() to open a log file named /var/log/signup.txt and add the e-mail to the list (and fclose() afterwards). Very simple.

This is all on a dedicated server. The system is default installation of CentOS 5.5. Web server is Apache 2, running PHP 5.1.6.

It was working fine (I had some 20 e-mails in the list) and this morning I went to /var/log/ and see that signup.txt file is truncated (zero bytes). I suspect this might be to some housekeeping cron job, but don't have a clue where to look. I understand that I lost the data, but how can I prevent this from happening again?

Thanks for any ideas.

eelixduppy

9:20 pm on Mar 8, 2011 (gmt 0)



There are a bunch of different variables at play here. Why do you suspect it is a cron jobbed task truncating the file? You can check what is going to run:
crontab -e
.

If nothing turns up come back and we can take a look at how you are writing to the file.

mbabuskov

11:43 am on Mar 9, 2011 (gmt 0)

10+ Year Member



I found it, there was one script run via cron that had a bug and accidentally truncated some files instead of backing them up. Problem solved.

Thanks for the tip, I actually used crontab -l, because it does not enter into editor mode.