Disabling logout window in Gnome on ctrl-alt-delete (on Ubunu and Debian Linux for example)

It was quite annoying every time I hit ctrl-alt-del in Gnome, the Logout window appeared – instead giving the combination to the active window (virtual machines, VNC, Remote Desktop connections, etc.).

Gladly this is just another global shortcut like any other ones (alt-F1 for menu, for example), therefore it can be disabled the same way: System menu » Preferences » Keyboard Shortcuts, in the window you can find under Desktop » Log out. Click on it, and disable it with a backspace.

Successfully got rid of an annoyance – “great success!” as my colleague said :)

Posted in: Uncategorized by kakaopor No Comments

Getting file age in a simple way

I just needed a way to detect regularly if a file has been changed recently. The solution I came up with was this:

now=`date +%s`
mtime=`stat -c %Z /some/file`
if [ $((now - mtime)) -gt 3600 ]; then
    echo "xy seems to be out-of-date."
fi

This checks the current time and the modification time of the file, calculates the difference and checks if that’s greater than 3600 seconds (1 hour), then echoes something if it is greater.

This can be written in a more simplest way:

[ $((`date +%s` - `stat -c %Z /some/file`)) -gt 3600 ] && \
    echo "xy seems to be out-of-date."

This way you can easily put it in cron, like this, so it is checked twice a day:

0 9,21 * * * user [ $((`date +\%s` - `stat -c \%Z /some/file`)) -gt 3600 ] && \
    echo "xy seems to be out-of-date."

You can remove the “\” at the end of the lines and write the commands in one line. BUT the “\”s before the “%” have to be there to maintain proper escaping!

Posted in: Uncategorized by kakaopor No Comments

Lunar date() function for PHP

What is the time on the Moon?

A few guys leading a project called LunarClock.org designed a Lunar date and time system, the Lunar Standard Time (LST).

It is a really simple method of the time tracking on the Moon (theoretically of course, as no one lives there – yet ;)). It based on the good old scheme of the “Earth time”: it has seconds, minutes, hours, cycles, days and years. The only unfamiliar thing is the cycles thing between the hours and days (and the lack of the months). It is necessary in case we stick to the definition of the day: the time between two noons. On the moon it is a really long period, it lasts for about 29.53 days on Earth! It would be a bit strange to say “it is half past 143″, so they introduced the cycles. And because the days are so long, 365.25 (or so) of them would be… a lot of days on Earth, therefore the months are dismissed and the Lunar years are simply 12 Lunar days long – about 354.36 Earth days. This is so close to our 365.25 days per year!

Another interesting thing is the days on Moon have names just as our months. They named the twelve days after the twelve men who walked on the Moon during the Apollo missions. I think this is a nice idea.

Well okay, enough of the chit-chat, here is a demo of the PHP class I mentioned in the title:

The current time on the Moon is 44-10-29 ∇ 06:24:57, Duke.

So this is the current time on the Moon, so far from here, so great differences between the days, but still very familiar.

Great job guys from LunarClock.org, I like LST!

You can download the PHP function (which can be used almost exactly as the original date() function) from here: http://dev.kakaopor.hu/stuffs/lunar_date.php.txt (can be freely used/redistributed/modified/etc. of course)

For more about the LST, Lunar Standard Time, see: http://lunarclock.org/

Posted in: Uncategorized by kakaopor No Comments

SSH connection timeout, frozen terminal

I’ve just found accidentally a solution for a very rare (at least I’ve seen it only a few times), but rather annoying SSH client issue (bug?). Sometimes when the SSH connection times out OR after a clean exit from the remote shell, the SSH connection hangs and the terminal remains virtually between the remote and local machine. You’re unable to do anything on the remote machine as the disconnection is in progress, but you cannot do anything on your local machine yet as the SSH client is still runnig.

The solution for this is an SSH escape sequence, the sequence of the enter, tilde and period keys (so you should press enter and then “~” followed by “.”). This forces the SSH connection to close so your client should exit.

Source: Way to avoid ssh connection timeout & freezing of terminal tab question on superuser.com.

Posted in: Uncategorized by kakaopor No Comments

Hot-swapping non-hot-swap SATA disks on Linux

Once I had a project where I needed to swap two SATA disks every week. Shutting down, swapping, and booting up again took a lot of time, and – to be honest – was a bit uncomfortable, so I thought I will try to make the change a little bit hot.

My disks and motherboard AFAIK were not hot-swap-compatible, but with some SCSI/SATA commands I was able to have a behavior very similar to that.

(more…)

Posted in: Uncategorized by kakaopor 2 Comments , , ,

Asus Eee 1101HA hangs

I have just bought an Asus Eee 1101HA and (after compiling a custom kernel with the correct drivers) it is working almost perfectly. Sometimes the whole system just hung and after a keypress the hung had gone and it was OK for a while until the next hang…

This had been happening in console and under X too. I thought it might be a kernel-related issue, some kind of a timer or interrupt problem, maybe timeout.

All in all this turned out to be an APIC problem, and the machine is working perfectly with a noapic boot parameter.

Posted in: Uncategorized by kakaopor No Comments , , , ,

LVM boot issue on Debian Linux with initramfs-tools

Although the format /dev/[vg_name]/[lv_name] format is easier to read when you got plenty of VGs (compared to /dev/mapper/[vg_name]-[lv_name]), it won’t work at boot.

This is the few lines of default initramfs script which is responsible for the behaviour described above:

/usr/share/initramfs-tools/scripts/local-top, from line 40:

# Make sure that we have a d-m path
vg=${vg#/dev/mapper/}
if [ "$vg" = "$1" ]; then
    return 1
fi

And it wouldn’t be enough to remove this check, because there is an another one for the format:

# Make sure that the device includes at least one dash
if [ "$(echo -n "$vg" | tr -d -)" = "$vg" ]; then
    return 1
fi

So you have to use the /dev/mapper/[vg_name]-[lv_name] format in GRUB’s menu.lst (or LILO’s lilo.conf) to boot from an LVM device. Unless you change the script above, of course :)

Posted in: Uncategorized by kakaopor No Comments , ,

5853:0001 XEN device

5853:0001 is a XEN HVM virtual SCSI adapter.

Source: https://code.ticketmaster.com/trac/browser/spine/trunk/lib/Spine/Plugin/SystemInfo.pm?rev=123#L225

Posted in: Uncategorized by kakaopor No Comments , ,

ORA-19502, ORA-27072 during RMAN restore (Oracle)

I was trying to load database from an RMAN backup (duplicate database until …), and the restore process died after some time, and gave me the following error messages (I have tried it several times, with different backups, these repeated randomly):

ORA-19502: write error on file "/path/to/datafile.dbf", blockno 1669073 (blocksize=8192)
ORA-27072: File I/O error
Linux Error: 2: No such file or directory

ORA-19502: write error on file "/path/to/datafile.dbf", blockno 1831475 (blocksize=8192)
ORA-27072: File I/O error
Linux Error: 13: Permission denied

Long story short, these messages are exotic forms of the boring “Out of disk space” message.

And even if you have enough space for the restore, you may need ~+20% spare space. Don’t know exactly why, but that was needed in my case.

Oracle loves disk space and strange messages – lesson learned.

Posted in: Uncategorized by kakaopor No Comments , ,

Bootsplash patch for Linux kernel 2.6.32

Although the Bootsplash has been superseded by Splashy many of us liked Bootsplash. I was unable to find a patch for 2.6.32, so I made one from the patch for 2.6.30.

http://dev.kakaopor.hu/stuffs/bootsplash-3.1.6a-2.6.32.diff

Posted in: Uncategorized by kakaopor 4 Comments , , ,
i
north-supercharged