erase file

I have a file that always generated in the system eg. /tmp/log.txt , it is generated by the application program , but this file should not be present in the system otherwise there are some program problem , I want to erase this file once the program has generate it , as I know , it can link to /dev/null , could suggest how to make it

I use the s.link function , it is OK to link the file , but the /tmp/log.txt is exist , even the file can't be update but I really don't want the file exist in the system , how can I make the file don't appear in the system ( even the file size is 0 ) ? thx

/tmp/log.txt -- > /dev/null

As you stated, link it to /dev/null if you don't want it. Instead of having the real file, it will be a link to /dev/null. Use a startup script to insure it's a link while booting (and have the script create it if it isn't there.) before the application starts. Realize that some testing may be needed as the application may not like the fact that it's a link.

I also wonder why, if this file is a sign of a program error, why you want to get rid of it - instead of fixing it so the file is a link to /dev/null, fix the program!

You can also truncate a file to size zero

Depending on your shell

> filename
# or
cat /dev/null > filename

And RTM has it - why not fix the program?