How to delete logs automatically after a certain time and restart the process that fills up the log file?
With logrotate
you can configure how big a log file may get or after how much time:
the log files are rotated (log.n becoming log.n+1, and the last log file being deleted)
the current log file is truncated without disturbing the writing process.
Take a look at man 8 logrotate
.
I guess that you start the script/program with nohup like
nohup scriptname 1>logfile.log 2>& &
I would recommend instead of deleting the log file just to clear it with
echo -n >logfile.log
If you delete/move an open file it will be written until the process will close the file or the process will end.