Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2791  / 1 Year ago, fri, december 9, 2022, 5:52:33

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.


More From » bash

 Answers
3

Write



#!/bin/bash
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.


[#42333] Friday, December 9, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
oredoise

Total Points: 66
Total Questions: 116
Total Answers: 111

Location: Lebanon
Member since Sun, Aug 2, 2020
4 Years ago
;