the syntax -how to output recent date and time to log file of the date command is like this:

echo "firewall started on: $(date '+%Y-%m-%d_%H-%M-%S')" >> /var/log/firewall.log

other examples:

date '+%Y-%m-%d-%H:%M:%S'
# or
echo $(date '+%Y-%m-%d-%H:%M:%S')

# create a file like 2022-02-01-filename.txt
touch $(date '+%Y-%m-%d')-filename.txt

# tar gz backups automatic date named name datum
tar fcvz $(date '+%Y-%m-%d')-projectname.tar.gz ./projectfolder

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin