[root@rhce-ryanrudolf]# rm -rf / 2> /dev/null

things I break/fix for fun and learning

Dec 19, 2017 - 1 minute read - Comments

Server Uptime Using Cron and Text File Manipulation

This page will display the uptime of this Linux server and refresh every 5minutes. Uptime is the number of hours / days that a server is powered ON - no restarts, no reboots, no buts. For personal preference, a server with high uptime is just pure awesome! That means a sysadmin was able to maintain the system in tip-top shape without the need for a reboot! Or it could also be the reverse!

Just keep refreshing the page every 5minutes and it will display the current system uptime. I’ve used several command-line utilities to automate this -

  • > - output redirection overwrite to file
  • >> - output redirection append to file
  • cron - execute the script every 5minutes
  • uptime - display the server uptime
  • head - display the beginning of the file
  • mv - rename files
  • rm - delete files
  • cp - copy files
  • chown - change ownership of files

And here it is, the uptime of this server is -

43 min

Like this page? Share it!