Linux Blog

Backup Utility Roundtable

Filed under: General Linux,Linux Software — TheLinuxBlog.com at 12:30 pm on Thursday, September 16, 2010

Did you remember to backup the files…?
All of them?
What do you mean *MOST* of them?
Well, you should have used one of these flippin’ utilities.
Off with his head!
(Read on …)

Timing your reboots with Twitter support!

Filed under: Shell Script Sundays — TheLinuxBlog.com at 12:01 am on Sunday, July 20, 2008

Firstly, I’d like to start off by saying that all of the concepts in this post should have been covered in other posts, so I will not go into great detail on the specifics of this script. If you need to know more information about any of the commands, check the man page section at the bottom of this page, from the man pages will be examples of other posts covering similar topics.

The purpose of this script for me was to time my reboot times. It could be modified to log the time it takes to replace hardware or add memory, but thats another post. Since we are logging reboot times, we are (hopefully) dealing with small numbers and therefore don’t have to deal with formatting time (at least not for now.)

The script should work on multiple systems that have bash. There is nothing too special about it. It uses the reboot command so the user this is launched as will have to have access to that command. You put the script in the users bin directory and chmod it. The user must also have write access to this. Also, they must have write access to their home directory, but this should not be a problem for most. Line 8 of the script needs to be changed to the user you plan on running this as.

After that test that the timereboot command works by typing timereboot:

[owen@linuxblog ~]$ timereboot
Usage: /home/linuxblog/bin/timereboot {time|ttime|back}

Once that is done, thats a pretty good indication that the script is working. Next, I suggest commenting out the reboot command on line #25 if this is a critical mission and you don’t want to reboot multiple times to get it working. If not go ahead and try the time command. Once your system is back up and your logged in you type the “timereboot back” command, it will then tell you the time taken since your system was done.

Once you have verified that the time works, you can go ahead and add it to your bashrc to automatically perform the action once your logged in. All you need to do is add a line like this:

home/linuxblog/bin/timereboot back

Now, if you want you can try again and see the results automatically.

“Thats great, but how do I post it to twitter?”

Well, there is one last thing that you have to do to get your reboot time posted to twitter. Edit line 55 and change to your twitter username and password. Do the same thing as before to reboot, but use the ttime parameter to log to twitter.

This script, does not post to twitter that you are rebooting (although it could) nor does it format the time, but it works and should give you a starting point if you are interested in doing this. It doesn’t really serve a real purpose other than to inform people how quickly or how slow you reboot. Also, please note that this is not a start up time. This times from when you issue the command until you issue the back command, or log in using the .bashrc method.

If you have any questions about this script or any other idea’s let me know and I’ll be happy to help or implement them for fun.

And here is the Twitter reboot script