Monday 7 September 2015

... shutdown a system at specific time

I need to shutdown a server at a specific hour a few days from now.  The command shutdown allows to specify the hour but the day so that can't be used.  It also allows to specify a number of minutes from "now" which implies computing that value.  So the following can be used:

sudo shutdown -h +$(($(($(date -d 'yyyy-mm-dd hh:mm:ss' +"%s") - $(date +"%s"))) / 60))

There is also the at command but I'm sure how that well that work with commands that would require sudo.

Wednesday 22 July 2015

... install bioformats in Debian and Ubuntu

Bioformats is not packaged in Debian and therefore, not in Ubuntu either. To install it in a way that will make it play best with the rest of the system, following the expected standards, use the following (adjusting the download URL for the bioformats version you want):

 sudo mkdir /usr/local/share/java/  
 sudo wget http://downloads.openmicroscopy.org/bio-formats/5.1.3/artifacts/bioformats_package.jar \  
  -O /usr/local/share/java/bioformats_package-5.1.3.jar  
 sudo ln -s bioformats_package-5.1.3.jar /usr/local/share/java/bioformats_package.jar  

This mimics how java packages are installed by Debian.  The actual jar has the version on the filename, while the unversioned filename is a symbolic link to a specific version.  This allows you to have multiple versions installed while keeping one (usually the latest) as the default.

apt would install those files in /usr/share/java so we place them in /usr/local/share/java instead. Remember that the whole /usr hierarchy should be considered off-limits, only the package manager should change things there.  The exception is /usr/local.  You can think of /usr/local being the equivalent as /usr that is managed by the system administrator instead of the package manager.  From the Linux Filesystem Hierarchy Standard:

The /usr/local hierarchy is for use by the system administrator when installing software locally.
[...]
Locally installed software must be placed within /usr/local rather than /usr unless it is being installed to replace or upgrade software in /usr.