Tag Archives: oneliners

Favourite command of the day – kodi-send

This is an update of a post I wrote a couple of years ago about triggering an update of OpenELECs media library since the XBMC project has since changed its name to Kodi.

For the videos now use:
OpenELEC:~ # kodi-send --action="KODI.updatelibrary(video)"

Also worth noting is that nowadays root seems to be the default login.

Share

Favourite command of the day – xbmc-send

Using xbmc-send one can remotely via SSH trigger a rescan of the media library. For example the videos like here below.
apathy:~ $ xbmc-send --action="XBMC.updatelibrary(video)"
Sending action: XBMC.updatelibrary(video)

The xbmc-send command can be used for a lot of things and is well worth looking further into.
This works fine for me on OpenELEC version 3.0.6.

Share

Quick script to poll parcel status

Sometimes when waiting for a package I like to check the status of it now and then (in reality this means every moment I have over – or rediculously often).
I also like to do things on the command line.

Enter small script of the day;
(this relates to Schenker in Sweden)

%cat schenker.sh
#!/bin/sh
if [ "${1}" = "" ] ; then
cat < Continue reading

Share

jail resources oneliner

Getting a quick overview of the resources currently assigned to your your jails can be done using the following command sequence:

top -Pajnojid | tail -n 20 | awk '{if ($2!=0) print $0}'

Starring in order of appearance:
top; with the flags P -Show info per CPU, a -get command name from argv[] and not the name of the executable, j -display jail id, n -non interactive mode, ojid -the order flag `o` followed by jid for sorting.
tail; to get the last 20 lines of output (skip the sys info)
awk; print all lines where column 2 is not `0`

if you have many jails and hence many jail processes you might want to bump up the number of lines a bit like follows to show a maximum of 50 processes instead of the default 20:

top -Pajnojid 50 | tail -n 52 | awk '{if ($2!=0) print $0}'

Share

oneliner of the day – ps

This is one of my old favourites, that is useful both for verifying what shell you are running and also the $$ variable is very useful for scripting and writing pid files, lock files, statuses etc.

Let’s have a look at it:
ps -p $$

What this does is tell ps to look at the process specified with the -p flag.
And in this case that is $$.
$$ is in turn a shell variable expanding to the pid of the current running process, in our case the shell.

Example output:
%ps -p $$
PID  TT  STAT      TIME COMMAND
47991  p0  Ss     0:00.03 -csh (csh)

$ ps -p $$
PID   TT  STAT      TIME COMMAND
5404 s002  S      0:00.02 ksh

[henrik@character ~]$ ps -p $$
PID TT STAT TIME COMMAND
40668 1 S 0:00.02 bash

henke@3(NXDOMAIN):~> ps -p $$
PID TTY TIME CMD
3152 pts/2 00:00:00 bash

(FreeBSD; Mac OS X, FreeBSD and OpenSuSe respectively)
You get the point.

Share