I use the command:
nohup <command to run> &
and it logs to the nohup.out file, however this log file could get pretty BIG so was wondering if there was a way to automatically save off the output to nohup1.out, nohup2.out nohup3.out etc when the nohup.out gets too big. This is all without terminating the original command.
Best Answer
logrotate(8)
is likely what you need and probably already in your Linux distro. Specify in /etc/logrotate.conf the size limit and how many rotations you want:From an example on thegeekstuff.com:
Then run
logrotate /etc/logrotate.conf
I ignored the example's file status location since
logrotate
is already running as a cron job by my system and a status file already exists (in a different location from the example's).