Delete a files contents through bash

,

So I was looking for a way to automatically overwrite a log file utilizing the command prompt and a cron job.  So this is how it can be accomplished.

cat /dev/null > /location/of/file.txt

By adding this to the crontab it will overwrite the file at whatever interval you set.  Very useful if a sites log file is getting filled up with warnings.

Skills

Posted on

August 27, 2015

Submit a Comment

Your email address will not be published. Required fields are marked *