Shell Script: Run Command at 10-Second Intervals

Shell script code for automating the execution of commands at 10-second intervals. Here is the sample code:

#!/bin/bash

# Infinite loop to keep the script running
while true
do
    # Command to execute
    echo "Current date and time:"
    date
    
    # Wait for 10 seconds before repeating the command
    sleep 10
done

Leave a Comment