A bash script that rotates a file (logfile.txt) to a timestamped
file(logfile_20180719.txt), which could be invoked by cron every 24 hours.
Move the created bash file to newly created scripts folder.
mv /home/hass/rotate.sh /var/scripts/rotate.sh
Change permission to allow +x (execute permissions)
I used the below site to generate the time for the cron job
https://crontab-generator.org/
Add the location of the script file to the crontab
Sudo crontab -e
Cron Job Generated (you may copy & paste it to your crontab):
1 1 * * * test >/dev/null 2>&1
Your cron job will be run at: (5 times displayed)
2019-11-19 01:01:00 UTC
2019-11-20 01:01:00 UTC
2019-11-21 01:01:00 UTC
2019-11-22 01:01:00 UTC
2019-11-23 01:01:00 UTC