Menu
His Majesty The King
  • Home
  • Forum
  • Contact Me
  • Advertise
  • About Me
His Majesty The King

Monitor Your Server With Cron

Posted on February 6, 2009June 3, 2019 by The King
Sometimes you find yourself in a situation where you want to know what your server is doing but you can't get to a secure terminal to SSH in. What do you do? You look to cron.

Cron is a daemon that can be found in Unix and Unix-like operating systems. What it allows you to do is execute commands at any hour of the day and you can even use it to run commands multiple times a day. Cron may be a daemon but it's an angel to most sysadmins.

There are two main ways to use cron. You can either put a script into a cron subdirectory or you can edit the crontab file.

Using the subdirectories is very simple. You can find them in /etc and they are: cron.hourly, cron.daily, cron.weekly and cron.monthly. As I am sure you can figure out the scripts inside these subdirectories are executed based on the name of the subdirectory. Sometimes you need a little more control over when your script is to execute, this is where crontab comes in.

When using crontab you edit the /etc/crontab and insert a line of code that tells cron when you want your command to run. You can customize the time frame down to the minute. You can have it run every 15 minutes or even have it run every 15 minutes but only between the hours of 9:00 and 17:00.

My favorite Unix command has to be top. You can get a wealth of information from this simple command but you need to be at a terminal to run it, or do you?

By using crontab you can set top to run at preset intervals throughout the day and have the results emailed to you.

*/15 * * * * root /usr/bin/top | mail -s "top results" admin@domain.com

That little bit of code above will have the top command run every 15 minutes (as root) and the output will be sent in an email to admin@domain.com with the subject "top results". Not bad, eh?

You could also use this to email yourself error logs, netstat information, anything really. Cron is a sysadmin's best friend.

Further Reading:
Configuring the cron Utility Facebooktwitterredditpinterestlinkedinmail
  • Cron
  • News
  • Server
  • Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    *

    code

    Tags

    Advertising Apple Blogging Board Games Campaign Card Games Cats D&D Digg DS Fail Fallout Fallout 3 Family Fiction FWE Google Heroes Humor Make Money Online Movies News Nintendo Opinion PC Pokemon Politics PS3 Review Rockwars Role Playing Games RPG Server Social Media Star Wars Stocks Story The Dice Tower Tom Vasel TV Video Games Weird Wii Wordpress xBox 360
    January 2021
    S M T W T F S
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  
    « Sep    

    Popular Posts

    • Building a town with MySims

      I have been spending the last week or two with EA's new MySims game for th...

    • Wii Sports Golf: Tips and Tricks

      So, you think you know how to play golf? You think you can just grab that...

    • .
      Dungeons and Dragons 5E Cantrips – Fire Bolt

      Now that I have returned to the realm of Dungeons and Dragons I find mysel...

    • Warhammer 40K: Lt. Varas

      I've been working on painting the miniatures that came with the WarHammer...

    • .
      Painting the UltraMarines

      I've been working on painting the miniatures that came with the WarHammer...

    • .
      Pokemon Ranger: Manaphy Egg?

      The Feb 2007 issue of Nintendo Power magazine mentions a special Egg you c...

    • .
      Dungeons and Dragons 5E Cantrips – Dancing Lights

      Dancing Lights is very useful when cast as a tactical spell. While it can n...

    • Wii Fit: The Unboxing

      As I mentioned in my earlier post today my copy of Wii fit arrived via UPS...

    • Pokémon Trading Card Game (TCG): Rumble

      On December 2, 2009 Pokemon International released the Pokémon Trading Car...

    • The Wii goes NASCAR

      No your eyes are not deceiving you that is indeed a NASCAR car with the Wi...

    Recent Posts

    • Papers Please!
    • Dungeons and Dragons 5E Cantrips – Dancing Lights
    • Can’t Run an App in Windows 10? Try System File Checker
    • The Beefed Up Gunners Project
    • Fallout 4 – Evan, part 1
    ©2021 His Majesty The King | Powered by WordPress & Superb Themes