Linux provides a neat utility called watch which we can use to run a command continuously at a specified intervals. This is useful when we have a long running task and we want to run a command repeatedly to monitor the progress of that task. A disk mirror operation is a good example.
I wrote a quick one liner to do something similar for UNIX (Solaris) as watch does for Linux.
So, here it is:
while true; do echo "lpq -P B-inst-printer1 at $(date)"; lpq -P B-inst-printer1; sleep 360; done
lpq -P B-inst-printer1 at Monday, July 31, 2017 01:44:03 AM GMT
no entries
lpq -P B-inst-printer1 at Monday, July 31, 2017 01:50:03 AM GMT
no entries
lpq -P B-inst-printer1 at Monday, July 31, 2017 01:56:05 AM GMT
no entries
I wrote a quick one liner to do something similar for UNIX (Solaris) as watch does for Linux.
So, here it is:
while true; do echo "lpq -P B-inst-printer1 at $(date)"; lpq -P B-inst-printer1; sleep 360; done
lpq -P B-inst-printer1 at Monday, July 31, 2017 01:44:03 AM GMT
no entries
lpq -P B-inst-printer1 at Monday, July 31, 2017 01:50:03 AM GMT
no entries
lpq -P B-inst-printer1 at Monday, July 31, 2017 01:56:05 AM GMT
no entries
This is a simple infinite while loop which will continue to run the specified command (print job status of a printer in this case) at an interval of 5 minutes implemented via a sleep.
You can further refine this one liner suited to your requirements. I hope this trick will prove useful to you in future.
No comments:
Post a Comment