1751880 Members
5043 Online
108783 Solutions
New Discussion юеВ

Re: cron job

 
Manal hassan
Occasional Contributor

cron job

hi all,
I have a file filled with constantly so i want doing job via cron to be empty as possible as.
please, help me
thanks
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: cron job

What OS version are you using?
Dennis Handly
Acclaimed Contributor

Re: cron job

What type of locking scheme do you have to prevent writing while the data is being processed? (Assuming you actually want to process the data and not just reset the EOF.) Is the writer continually opening and closing the file?
Jose Mosquera
Honored Contributor

Re: cron job

Hi,

If information dump is useless you can replace that file by a symbolic link that aims to /dev/null (a black hole file), in this way the file size always will be null.
First step is stop the process that fill your_file.
Then go at your_file location
Remove or rename your_file
Replace your_file by a symbolic link:
#ln -s /dev/null you_file
#ls -l your_file
lrwxr-xr-x 1 root sys 9 Mar 21 17:12 your_file -> /dev/null
Restart the proccess again

Rgds.
TwoProc
Honored Contributor

Re: cron job

If a totally empty file is what you want, then Jose just gave the answer to what I use, but with a change.

I create a new device file, just like /dev/null (using mknod), and name it something else, like "bitbucket". And then, I make a symbolic link to it just like Jose said.

The reason is that if root ever does a "chmod" on a set of files which happen to include the link to /dev/null, it will change the permissions to /dev/null as well, following the symbolic link. The risk here is that the "w" flag will be changed to being inaccessible, by root, group, or everyone, breaking lots of code, network printing functionality (which needs write access to /dev/null), etc.

And yes, I found this out the hard way. :-)

We are the people our parents warned us about --Jimmy Buffett