Linux putting output file in a log files folder

I modified my startserver.sh on this line:
./7DaysToDieServer.x86_64 -logfile "$SERVERDIR"/logs/output_log__`date +-%d__%H-%M-%S`.txt -quit -batchmode -nographics -dedicated $PARAMS

I added a logs file directory in the 7days folder so the output log files did not clutter the main 7days server folder.

I am adding a cleanup script to run weekly to delete old log files to save on server space.

I still need to test this line to ensure no running server breakage ,but this should be the command string to clean things:
find /home/7days/7days/logs -maxdepth 1 -type d -name "output_log__*" -mtime +7 -exec rm -rf {} \;
 
OK, I got a working output log file cleaner script.

I placed the file in /usr/local/bin
and
gave it execute privilidges with sudo chmod +x

contents of file as follows:
#!/bin/bash
find /home/7days/7days/logs -maxdepth 1 -type f -printf '%Ts\t' -print0 \
| sort -rnz \
| tail -n +2 -z \
| cut -f2- -z \
| xargs -0 -r rm -f

NOTE: the above command by itself is only runnable as root, access root console by typing: su - then entering the root password

I named the file outputlogclean.sh

I then added it to crontab to run weekly (sunday at midnight) with: sudo crontab -e
added the line
@weekly /usr/local/bin/outputlogclean.sh
hit ctrl+x, hit y, then enter
 
Back
Top