Forum Moderators: coopster

Message Too Old, No Replies

How to erase content?

         

mooger35

11:39 pm on Jul 3, 2006 (gmt 0)

10+ Year Member



What I want to do is write to a file (no problem... I figured this out) but if there is already text there I want to clear it before writing to the file (this is where I'm stuck).

jatar_k

11:47 pm on Jul 3, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



when you use fopen [php.net] just use the w mode

Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.

mooger35

1:02 am on Jul 4, 2006 (gmt 0)

10+ Year Member



wonderful!

Works great.

now final question. I have the file (write.php) that will erase then rewrite the file in question.

I would like to set up a cron job to run this file (write.php). How do I do that with cpanel 2.5's cron job function?

Command to run:?

Thanks!

ps: I hope this is okay to ask in this forum.

mcavic

2:46 am on Jul 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't use cpanel, but for running php scripts from cron, I usually use something like:
/usr/bin/php /home/mcavic/write.php