shell - How to create a bash script that every 5 minutes insert a record in a log file? -


this question has answer here:

i new bash scripting , need create simple script every 5 minutes insert date , time log file , save it.

what can do it? can start?

the date command output current date , time. can append output of command file >>. finally, sleep pause script specified amount of seconds.

#!/bin/bash while true;     date >> /path/to/the/logfile/dates.log     sleep 300 done 

the date command provides options modify format of output, if optionless output not suit needs.

alternatively, issue

crontab -e 

and add line

 */5 * * * * date >> /path/to/the/logfile/dates.log  

of course, can use name logfile, dates.log placeholder used.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -