Ubuntu – How to append text to file every morning


I would like to append current date to text file every morning at 7am. if the computer is turned off I would like it to be executed after its turned on.

Best Answer


date +%Y-%m-%d >> /path/to/file

Save that in a file under /etc/cron.daily/ and make it executable. It's important that the file does not have an extension.

The files in /etc/cron.daily/ are run daily by anacron in the morning (not exactly 7am, but around then) or during boot if it hasn't already been run that day.