| Mobile | RSS

Update Your Linux Box Status to Twitter

August 20th, 2008 | 7 Comments | Posted in Editorial, Featured Post, Information, Script, Tips, Tutorials

From few days my PC has started twitting ! Ya you heard right my PC is twitting now days. Its really a great thing to get your PC status through twitter . Please note that there may be different method of doing the following . I’ve dove what I liked. Step First Register a Twitter account for your PC . Step Two Create a shell script for twitter API :D [ need curl to be installed on your Linux Box ]

#!/bin/bash curl -u username:password -d status=”$*” http://twitter.com/statuses/update.xml

Replace the above user name and password with your own credential Step Three Set a cron job [ cron job will run your script after every specific time ] to set cron job just log into superuser mode and pass following command [ this command checked on Redhat,Fedora Core and Suse]

#crontab -eu root

and after that command add the following lines into your cron job

*/10 * * * * /bin/sh /path/to/your/twitter/script.sh My PC uptime is $(uptime)

If you need any sort of help or to get a customized output please feel free to leave comment and save the cron job and restart the cron job To restart cron job in REDHAT and FEDORA CORE

# service crond restart

For Suse [ I've tested this on suse 11 ]

# service cron restart

So now Your PC will update its status over twitter every 10 mins to change. If your want your PC to send his update every one hour use following

* */1 * * * /bin/sh /path/to/your/twitter/script.sh My PC uptime is $(uptime)

The Following Expectation have been taken from the author to the reader !!!

1)You might be running Fedora , Redhat or Suse [ altough I've not tested on ubuntu / debian the process may be same ]

2)You know basic vi / vim operation !! you need this knowledge to know how to save a file !!

3)you know basic of crontab . BTW if you dont know I will explain it just leave your comments :D

4)User should not abuse the service of twitter for this !! :-|

5)User Will add a cron job for deleting root mails too or have any other solutions [ you will get a mail in inbox everytime when a cronjob is executed ]

Special Thanks to Anoj Ramaswamy Sundar for http://anojrs.blogspot.com/2008/03/twittering-from-command-line.html This is base of the whole article without which it was not possible to write this article :D apart from getting only uptime you can even know your server status :-|

*/10 * * * * /bin/sh /path/to/your/twitter/script.sh $(service mysql status)

above will publish mysql status [ replace mysql with mysqld in fedora and redhat ]

Leave a Reply 2853 views, 7 so far today |
Follow Discussion

7 Responses to “Update Your Linux Box Status to Twitter”

  1. Reeteshinator Says:

    Thats really nice! we can use that in many other ways too.

    Thanx for the heads up :D

  2. Sathya Says:

    Nive, will link this on my blog, maybe tomorrow or day after :D

  3. Kunal Gautam Says:

    @Sathya Thanks :-*

  4. Sajal Kayan Says:

    Neat way….
    my contrib :p

    */10 * * * * /bin/sh /path/to/your/twitter/script.sh uptime=$(uptime)|Mysql=$(ps aux | grep -v grep | grep -c mysql)|Apache=$(ps aux | grep -v grep | grep -c httpd)

    on fedora/centos mysql becomes mysqld

  5. Kunal Gautam Says:

    @Sajal Kayan Nice sharing Bro

  6. Shoban Says:

    Winderful article…. Now I am going to monitor my ubuntu server using a twitter account. Thank you very much :)

Trackbacks

  1. I am tweeting : with luv my Ubuntu Server - www.crankup.net  

Leave a Reply