Oct 122014
 

Article by Mikko Ohtamaa first posted on his blog

Often you want to automatize something using shell scripting. In a perfect world your script robot works for you without getting tired, without hick-ups, and you can just sit at the front of your desk and sip coffee.

31451391

Then we enter the real world: Your network is disconnected. DNS goes downs. Your HTTP hooks and downloads stall. Interprocess communication hangs. Effectively this means that even if your script is running correctly from the point of operating system it won’t finish its work before you finish your cup of coffee.

Continue reading »

Flattr this!

Aug 252013
 

Recently I installed a Debian 7 VPS on Linode and as first thing I wanted to do an update of the system, but I found a small problem in doing this :

# apt-get update
0% [Connecting to ftp.us.debian.org (2610:148:1f10:3::89)] [Connecting to security.debian.org (2607:ea00:101:3c0b:207:e9ff:fe00:e595)]
Get:1 http://ftp.us.debian.org wheezy Release.gpg [1,672 B]                                                                           
...
Get:15 http://security.debian.org wheezy/updates/main Translation-en [56.6 kB]
Fetched 16.3 MB in <strong>4min 0s</strong> (67.5 kB/s)                                                                                                                                     
Reading package lists... Done

So 4 minutes to just update my repositories (and I had just the default for a Debian 7 just installed), this is due to the fact that linode VPS are IPV6 ready and so the servers of this company try to connect to security.debian.org via its IPv6 address by default when running apt-get update, and that results in having to wait for a lengthy timeout whenever you try to download updates of any sort.

But luckily change the system so apt-get will use IPV4 it’s not so hard.
Continue reading »

Flattr this!

Jun 192013
 

Sometimes it’s useful to write a bash script that do something like “Do this job, if it’s still running after XX second kill it”, how to implement this in a normal bash environment ?

Nothing simpler: Use the timeout shell command to achieve this.
From its info page:

timeout runs the given COMMAND and kills it if it is still running after the specified time interval

Let’s see how to use it.

Continue reading »

Flattr this!