You Are Here: Home » Ideas » Linux » Programming

Broadcast your computer`s start time and shutdown time to twitter

By Debjit on July 12th, 2009 

You can use the twitter api, curl, your twitter account and an always on Internet connection to broadcast the start and shutdown times of your workstations. This can be done with the help of this nifty little script.

Its here:

#!/bin/bash - script to send the computer start time and date to twitter (from LJ)

$curl --basic --user "$user:$pass" --data-ascii \
"status=`echo yourmessage $xd | tr ' ' '+'`" \
"" >& /dev/null
exit 0

Now, you have to do some more hacking of the /etc/rc.d directory to make this twitt thing happen every time you start your workstation and shut it off. All you need to do is save the above script code with a name say, xyz and then place place it in your home directory.  Run the script given below, as root, for the final twitt thing to happen:

#Final config for the twit start and stop script (from dkd903)

cp /home/$1/$2 /etc/rc.d/init.d/
chmod +x /etc/rc.d/$2
ln -s /etc/rc.d/init.d/$2 /etc/rc3.d/S99$2    #Runlevel 3
ln -s /etc/rc.d/init.d/$2 /etc/rc5.d/S99$2    #Runlevel 5
ln -s /etc/rc.d/init.d/$2 /etc/rc6.d/S00$2    #Shutdown Script
ln -s /etc/rc.d/init.d/$2 /etc/rc0.d/S00$2    #Restart Broadcast
exit 0

finally save this above code as abc. and execute it by passing your box`s userid and the xyz, the name that you saved the above script with. You can check my twitter, to see the above thing at work!

UPDATE: If you are a complete n00b then forget what you have read above and try this:

1) Locate the /etc/rc.local file and open it with the text editor of your choice (Vi / Vim / eMACS / gedit tch tch).

2) append the contents of the file above into it and save the file, and reboot. Open your twitter to check out the magic 😉


Broadcast your computer`s start time and shutdown time to twitter was originally published on on May 26, 2009 - 2:28 pm (Indian Standard Time)