Forums

How to automatically delete/clear the log file from a task

I have a task which runs every day at a specific time. I noticed that the logfile is not cleared, the info of the latest run is added to the same logfile, which makes the logfile to large and difficult to read. Is there a way to clear the logfile automatically (e.g. before a new run starts) ?

You can use something like this:

echo '' > /var/log/log-file-.log

to clear the log file.