For many cases, we need to execute the command repeatedly in the shell. We can do it by cron. But in that cat its not feasible to use cron if the interval time is less than 1 min or more. Suppose, we are inclined to get the output like the top command for a specific command. We can do that in the following ways as:
Watch Command:
Watch is a Linux command to execute a command periodically asn shows the output in the screen.
The above command execute the free -m command repeatedly with the interval of 2 seconds in default. In case of changing the default interval period we can execute the command as:
in that case, the above query will return with the out for each 10 second of interval.
other useful options of watch command:
-b : creates the beep sound, if the exit of the
-c: Interprets the ANSI color of the sequence
-d : highlight teh changes in the command output
we can monitor the progress of the copy command by checking the disk usage[du command] of the newly copied file at the time of copying as:
Sleep Command:
We can use sleep command inside a loop as the interval period to execute the desired command or script repeatedly as:
inside For Loop:
inside While loop:
Watch Command:
Watch is a Linux command to execute a command periodically asn shows the output in the screen.
The above command execute the free -m command repeatedly with the interval of 2 seconds in default. In case of changing the default interval period we can execute the command as:
in that case, the above query will return with the out for each 10 second of interval.
other useful options of watch command:
-b : creates the beep sound, if the exit of the
-c: Interprets the ANSI color of the sequence
-d : highlight teh changes in the command output
we can monitor the progress of the copy command by checking the disk usage[du command] of the newly copied file at the time of copying as:
Sleep Command:
We can use sleep command inside a loop as the interval period to execute the desired command or script repeatedly as:
inside For Loop:
inside While loop:
No comments:
Post a Comment