bash script for time
Hello Friends,
How to create a script which would print time to a file every 10 seconds for an hour ? |
Quote:
Hints: Have a look at the date and sleep commands. |
How about a one liner?
Quote:
|
|
Quote:
Code:
#!/bin/bash |
Code:
for n in `seq 360`; do date >> FILE; sleep 10; do |
Thank You for prompt replies !
|
Note: None of the solutions is accurate.
The problem is that though the sleep is accurate, it doesn't account for the delay caused by writing the data to the file. Things like how busy the system is, memory pressure all affecting paging, which will slow things down.. Now it can be sufficient... but over an hour the time will drift by several seconds. So it depends on what you are trying to do as to how well it works. |
I guess (showing :Dff) every one missed this "3 members found this post helpful."
|
Oh well, why to wait 1 hour when you can do it in 1 second?
Code:
for i in {0..3600..10}; do date -d "00:00 $i seconds"; done |
All times are GMT -5. The time now is 04:47 AM. |