{"id":42085,"date":"2018-11-30T03:01:31","date_gmt":"2018-11-29T17:01:31","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=42085"},"modified":"2018-11-30T05:30:47","modified_gmt":"2018-11-29T19:30:47","slug":"linux-watch-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-watch-primer-tutorial\/","title":{"rendered":"Linux Watch Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/watch.m4v\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Linux Watch Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/watch.jpg\" title=\"Linux Watch Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Linux Watch Primer Tutorial<\/p><\/div>\n<p>Command line work, when you are wanting to monitor something in real time, can be a tad repetitive, using the keyboard up arrow a lot in our case.  But there is the &#8230;<\/p>\n<ul>\n<li>Linux command <a target=_blank title='Linux watch information' href='https:\/\/linux.die.net\/man\/1\/watch'>watch<\/a> &#8230;<br \/>\n<blockquote cite='https:\/\/linux.die.net\/man\/1\/watch'><p>\nwatch runs command repeatedly, displaying its output (the first screenfull). This allows you to watch the program output change over time. By default, the program is run every 2 seconds; use -n or &#8211;interval to specify a different interval.\n<\/p><\/blockquote>\n<p> &#8230; meaning for &#8220;df -h&#8221; (disk space) monitoring, for example &#8230;<br \/>\n<code><br \/>\nwatch -d \"df -h\"<br \/>\n<\/code><br \/>\n &#8230; not on Mac OS X &#8230; but never fear &#8230; <a target=_blank title='Useful link' href='https:\/\/www.atkinson.kiwi\/programming\/watch-macos.html'>this useful link<\/a> helped us to &#8230;\n<\/li>\n<li>Mac OS X &#8230;<br \/>\n<code><br \/>\nwhile clear; date; df -h; do sleep 2; done<br \/>\n<\/code>\n<\/li>\n<\/ul>\n<p> &#8230; that you can stop with Ctrl-C keyboard press.<\/p>\n<p>Other monitoring ideas (that you could substitute in for &#8220;df -h&#8221; above) could be &#8230;<\/p>\n<ul>\n<li>show current date and time<br \/>\n<code><br \/>\ndate<br \/>\n<\/code><br \/>\n &#8230; up in right hand corner?  &#8230; try &#8230;<br \/>\n<code><br \/>\nwhile sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done &<br \/>\n<\/code>\n<\/li>\n<li>top 5 resource hungry processes<br \/>\n<code><br \/>\nps aux | sort -nrk 3,3 | head -n 5<br \/>\n<\/code><br \/>\n &#8230; or perhaps try something like &#8230; top | head -17 | tail -5\n<\/li>\n<li>last 5 files in current folder<br \/>\n<code><br \/>\nls -clt | egrep -v '^t' | egrep -v '^d' | head -5<br \/>\n<\/code>\n<\/li>\n<li>disk space<br \/>\n<code><br \/>\ndf -k \/<br \/>\n<\/code>\n<\/li>\n<li>disk inode count<br \/>\n<code><br \/>\ndf -i<br \/>\n<\/code>\n<\/li>\n<li>history of last logged in users<br \/>\n<code><br \/>\nlast<br \/>\n<\/code>\n<\/li>\n<li>outputs all the service\/process using port 80<br \/>\n<code><br \/>\nlsof -iTCP:80 -sTCP:LISTEN<br \/>\n<\/code>\n<\/li>\n<\/ul>\n<p> &#8230; the list can go on and on.<\/p>\n<p>We hope you find this tip <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/watch.jpg\" title=\"Click picture\">helpful<\/a> &#8230;<\/p>\n<p><video controls><source src='http:\/\/www.rjmprogramming.com.au\/Mac\/watch.m4v' type='video\/mp4'><\/source><\/video><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d42085' onclick='var dv=document.getElementById(\"d42085\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/linux\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d42085' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Command line work, when you are wanting to monitor something in real time, can be a tad repetitive, using the keyboard up arrow a lot in our case. But there is the &#8230; Linux command watch &#8230; watch runs command &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-watch-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,37],"tags":[707,725,2752,809,1319,1719],"class_list":["post-42085","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-linux","tag-mac-os-x","tag-monitor","tag-monitoring","tag-tutorial","tag-watch"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/42085"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=42085"}],"version-history":[{"count":5,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/42085\/revisions"}],"predecessor-version":[{"id":42099,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/42085\/revisions\/42099"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=42085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=42085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=42085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}