Archive for category Administration

Installing Java on Debian

centOS 6

If you need to install Oracle Java on Debian, you can follow the next steps once the binary file had been downloaded from Oracles’s download page:

Once it has been downloaded, proceed to extract it into the /opt directory:

# tar xvzf jdk-8u45-linux-x64.tar.gz

First let’s check the current java version:

# java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

Here you can see it points to OpenJDK’s 1.7.0_79 version. Now let’s add a path to the version to use:

# update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_45/bin/java 1

Last line adds the /opt/jdk1.8.0_45/bin/java path to /usr/bin/java java  binary, in other words, it creates a symbolic link to use in case that options is chosen. Let’s set an alternative that points to the new path:

# update-alternatives --config java
  Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
 1 /opt/jdk1.8.0_45/bin/java 1 manual mode
 2 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
 3 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
 Enter to keep the current selection[+], or type selection number: |

After choosing the option 1, check the java version one more time:

# java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Now the binary points to the Oracle’s version. You can check it with the symbolic links:

# ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 jun  9  2014 /usr/bin/java -> /etc/alternatives/java

# ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 25 jun 15 09:21 /etc/alternatives/java -> /opt/jdk1.8.0_45/bin/java

 

 


,

3 Comments

How to extend a volume on LVM

Sometimes it is necessary to extend a logical volume, expanding the physical volume where it is hosted. If this is the case, you can follow this example extending a volume of 450 GB to 500 GB: First, Let’s check the disk geometry:

:~# fdisk -l /dev/sdb
Disk /dev/sdb: 483.2 GB, 483183820800 bytes
 255 heads, 63 sectors/track, 58743 cylinders, total 943718400 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x0001178e

After expanding the volume you must make the system to rescan the volume:

:~# echo 1 > /sys/block/sdb/device/rescan

Then check the disk geometry one more time:

:~# fdisk -l /dev/sdb
Disk /dev/sdb: 536.9 GB, 536870912000 bytes
 255 heads, 63 sectors/track, 65270 cylinders, total 1048576000 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x0001178e

As you can see, the disk size grew up but this is only known by the operating system, because the LVM still has the same information since the physical volume hasn’t been expanded yet:

:~# pvs
 PV VG Fmt Attr PSize PFree
 /dev/sda5 debian lvm2 a-- 3.76g 0
 /dev/sda6 debian lvm2 a-- 13.00g 0
 /dev/sdb svn_vg lvm2 a-- 450.00g 0

If you extend the physical volume with the following command:

:~# pvresize /dev/sdb
 Physical volume "/dev/sdb" changed
 1 physical volume(s) resized / 0 physical volume(s) not resized

And check the physical volume sizes you will see the added space:

:~# pvs
 PV VG Fmt Attr PSize PFree
 /dev/sda5 debian lvm2 a-- 3.76g 0
 /dev/sda6 debian lvm2 a-- 13.00g 0
 /dev/sdb svn_vg lvm2 a-- 500.00g 50.00g

Now you have to extend the logical volume and the system file size on the fly. You can do both actions using just one command:

:~# lvresize -r -L +50G /dev/mapper/svn_vg-svn
 Extending logical volume svn to 500.00 GiB
 Logical volume svn successfully resized
 resize2fs 1.42.5 (29-Jul-2012)
 Filesystem at /dev/mapper/svn_vg-svn is mounted on /var/data/svn; on-line resizing required
 old_desc_blocks = 29, new_desc_blocks = 32
 Performing an on-line resize of /dev/mapper/svn_vg-svn to 131070976 (4k) blocks.
 The filesystem on /dev/mapper/svn_vg-svn is now 131070976 blocks long.

Finally, check the free space available to see the added 50 GB in the system file:

:~# df -h
 Filesystem Size Used Avail Use% Mounted on
 rootfs 993M 287M 655M 31% /
 udev 10M 0 10M 0% /dev
 tmpfs 397M 228K 397M 1% /run
 /dev/mapper/debian-root 993M 287M 655M 31% /
 tmpfs 5.0M 0 5.0M 0% /run/lock
 tmpfs 794M 0 794M 0% /run/shm
 /dev/sda1 228M 34M 183M 16% /boot
 /dev/mapper/debian-home 2.0G 39M 1.9G 3% /home
 /dev/mapper/debian-tmp 3.9G 7.1M 3.7G 1% /tmp
 /dev/mapper/debian-usr 2.0G 869M 1.1G 46% /usr
 /dev/mapper/debian-var 6.7G 2.1G 4.3G 33% /var
 /dev/mapper/svn_vg-svn 493G 432G 62G 88% /var/data/svn

,

2 Comments

How to move a physical volume on LVM

LVM move

If you need to move data from one disk to another one you could think in copying the data with cp, rsync, or any other tool, and then umount the partition, edit the /etc/fstab file to point to the new path, and all that involve to remove a disk or partition for another one. But if you forcasted and partitioned using LVM, there is a cleaner way of changing partitions on the fly, I mean, without umounting partitions and even leaving the same references in the /etc/file, because the same LVM partition will be used. Let’s see an example: if you have a 50 GB disk as a physical volume in /dev/sdb, which is set in a volume grup called data, and you need to move all data to another disk /dev/sdc, just do the following. First the initial distribution si shown:

LVM concepts

You can check the current state of the physical volumes using the pvs command:

# pvs
PV VG Fmt Attr PSize PFree
 /dev/sda2 system lvm2 a- 19.77g 0 
 /dev/sdb data lvm2 a- 50.00g 0

Then create the physical volume where the data will be moved:

# pvcreate /dev/sdc
 Physical volume "/dev/sdc" successfully created

Check the physical volumes again:

# pvs
PV VG Fmt Attr PSize PFree 
 /dev/sda2 system lvm2 a- 19.77g 0 
 /dev/sdb data lvm2 a- 50.00g 0 
 /dev/sdc lvm2 a- 50.00g 50.00g

Now check the volume groups:

# vgs
VG #PV #LV #SN Attr VSize VFree
 data 1 1 0 wz--n- 50.00g 0 
 system 1 6 0 wz--n- 19.77g 0

As you can see the volume group called data sizes 50 GB. Because this is the volume group which have the physical volume you want to move (/dev/sdb), you must add the physical volume to this group:

# vgextend data /dev/sdc
 Volume group "data" successfully extended

If you check it one more time you will see that the volume group has 100 GB  which correspond to  /dev/sdb (0 GB free) y /dev/sdc ( 50 GB free):

# pvs
PV VG Fmt Attr PSize PFree 
 /dev/sda2 system lvm2 a- 19.77g 0 
 /dev/sdb data lvm2 a- 50.00g 0 
 /dev/sdc data lvm2 a- 50.00g 50.00g
# vgs
 VG #PV #LV #SN Attr VSize VFree 
 data 2 1 0 wz--n- 99.99g 50.00g
 system 1 6 0 wz--n- 19.77g 0

Now let’s proceed to move the data from the physical volume  /dev/sdb to /dev/sdc:

LVM move

# pvmove /dev/sdb
/dev/sdb: Moved: 0.0%
/dev/sdb: Moved: 11.8%
/dev/sdb: Moved: 30.5%
/dev/sdb: Moved: 75.7%
/dev/sdb: Moved: 95.0%
/dev/sdb: Moved: 99.3%
/dev/sdb: Moved: 100.0%

There is not need to specify the other volume because the data will be distributed among the remaining physical volumes of the volume group, and in this case it is just /dev/sdc. Now, let’s check the distribution of the physical volumes:

# pvs
PV VG Fmt Attr PSize PFree 
 /dev/sda2 system lvm2 a- 19.77g 0 
 /dev/sdb data lvm2 a- 50.00g 50.00g
 /dev/sdc data lvm2 a- 50.00g 0

As you can see the /dev/sdb has no data (50 GB free) while /dev/sdc has the data (0 GB free). Just

Como puede verse el disco /dev/sdb no tiene datos (50 GB libres) mientras que /dev/sdc tiene los datos (0 GB libres). Now remove the physical volume to disincorporate from the volume group:

# vgreduce data /dev/sdb
 Removed "/dev/sdb" from volume group "data"

Now check the volume groups and the physical volumes:

# pvs
PV VG Fmt Attr PSize PFree 
 /dev/sda2 system lvm2 a- 19.77g 0 
 /dev/sdb lvm2 a- 50.00g 50.00g
 /dev/sdc data lvm2 a- 50.00g 0
# vgs
VG #PV #LV #SN Attr VSize VFree
 data 1 1 0 wz--n- 50.00g 0 
 system 1 6 0 wz--n- 19.77g 0

Finally proceed to wipe the physical volume::

# pvremove /dev/sdb
 Labels on physical volume "/dev/sdb" successfully wiped
# pvs
PV VG Fmt Attr PSize PFree
 /dev/sda2 system lvm2 a- 19.77g 0
 /dev/sdc data lvm2 a- 50.00g 0

This allows data to be moved from one disk to another without copying the data on operating system level, without interrupting services or restarting the computer. At the end we will have the disk /dev/sdc as the physical volume of the volume data as shown below:

LVM final

Reference: http://www.tldp.org/HOWTO/LVM-HOWTO/removeadisk.html

,

2 Comments

Debmirror problem: gpgv: Can’t check signature: public key not found

NoMirror.jpg

I have a mirror where  Debian and Ubuntu packages are hosted ,so people in the internal network can upgrade their software using this mirror. But the other day I realized it couldn’t sync against the Debian mirror, as described in the article How to build Debian and Ubuntu mirrors using debmirror. When I tried to run the sync script I got an error and it exited with errors.

Symptoms
When running debmirror script, it fails with a error similar to this one:

gpgv: Signature made Wed 17 Jul 2013 04:40:31 PM CST using RSA key ID 473041FA
[GNUPG:] ERRSIG AED4B06F473041FA 1 2 00 1374050431 9
[GNUPG:] NO_PUBKEY AED4B06F473041FA
gpgv: Can’t check signature: public key not found
gpgv: Signature made Wed 17 Jul 2013 04:40:31 PM CST using RSA key ID 46925553
[GNUPG:] ERRSIG 8B48AD6246925553 1 2 00 1374050431 9
[GNUPG:] NO_PUBKEY 8B48AD6246925553
gpgv: Can’t check signature: public key not found
Release signature does not verify.

Cause

Packages are validated using a key, so we can trust what we are downloading from the source repo and what will installed on our computers. Some repositories have a keyrnig with known keys, and it’s likely that a new key signature was added to the Debian/Ubuntu keyring. This can occur  if there is new distro version, and new keys were added, making our keyring out of date (the new keys are missing).

Solution

In order to fix this issue, follow the next steps depending on the distro you are mirroring:

Debian

Update the repository and import the new keys:

aptitude update
aptitude safe-upgrade
gpg --keyring /usr/share/keyrings/debian-archive-keyring.gpg  --export | gpg --no-default-keyring --keyring /var/data/keyrings/debian/trustedkeys.gpg --import

Sidenote: If no keys were added, download the latest debian-archive-keyring package from the repositories, extract it and use those keyrings. Example:

wget http://ftp.us.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2012.4_all.deb
dpkg -x debian-archive-keyring_2012.4_all.deb  ~
gpg --keyring ~/usr/share/keyrings/debian-archive-keyring.gpg  --export | gpg --no-default-keyring --keyring /var/data/keyrings/debian/trustedkeys.gpg --import

Ubuntu

Download the latest ubuntu-archive-kering package and extrack it,  later use the those keyrings . Example:

wget http://mirror.pnl.gov/ubuntu//pool/main/u/ubuntu-keyring/ubuntu-keyring_2012.05.19_all.deb
dpkg -x ubuntu-keyring_2012.05.19_all.deb ~
gpg --keyring ~/usr/share/keyrings/ubuntu-archive-keyring.gpg --export|gpg --no-default-keyring --keyring /var/data/keyrings/ubuntu/trustedkeys.gpg --import

After this procedure, the sync script will run without problems and it will downloaded the latest updates.

, ,

2 Comments

100 Linux questions!

LPI CompTIA Linux+

100 Preguntas de Linux

Este cuestionario busca evaluar qué tanto sabes de Linux, además de ayudarte en los exámenes de certificación de Linux existente en el mercado, tales como LPI o CompTIA.

Puedes ir respondiendo cada pregunta, marcar algunas en las que tengas dudas para revisarlas posteriormente, y finalmente terminar con el cuestionario donde se mostrará el resultado obtenido. También puedes revisar las respuestas si haces clic en Comprobar las preguntas para que sepas las preguntas que respondiste correcta e incorrectamente, para que en caso de que te hayas equivocado sepas qué temas debes revisar.

Suerte!!


, ,

19 Comments

How to create a ramdisk in Linux

ramdisk

A ramdisk is like a disk partition but running directly from the system’s RAM. All data read and written will be faster, and as drawback all data will be erase when you reboot the system. Some Linux distributions use this kind of file system to avoid killing the media, for instance instead of using a files system on a SD Card you can use a ramdisk.

If you need to create a partition of this type here is explained how to do it.

Creating the ramdisk with mount

To create the ramdisk in /tmp/ramdisk type the following commands:

# mkdir /tmp/ramdisk

# chmod 1777 /tmp/ramdisk

# mount -t tmpfs -o size=8G tmpfs /tmp/ramdisk/

 # df -h

 Filesystem Size Used Avail Use% Mounted on
 /dev/sda5 9.2G 533M 8.2G 6% /
 udev 7.9G 4.0K 7.9G 1% /dev
 tmpfs 3.2G 308K 3.2G 1% /run
 none 5.0M 0 5.0M 0% /run/lock
 none 7.9G 0 7.9G 0% /run/shm
 /dev/sda1 268M 50M 204M 20% /boot
 /dev/sda6 9.2G 552M 8.2G 7% /usr
 /dev/sda7 19G 172M 18G 1% /tmp
 /dev/sda9 490G 560M 464G 1% /var
 /dev/sda8 6.5G 143M 6.0G 3% /usr/local
 tmpfs 8.0G 0 8.0G 0% /tmp/ramdisk

Here you can see that the mount command creates a ramdisk by specifying tmpfs as the file system type, the size is given with the size option, and the mount point (which has all permission and the sticky bit enabled).

Creating the ramdisk from the /etc/fstab

If you want changed to be permanent you must add the following line to the /etc/fstab as shown below:

# RAM disk ramdisk
/tmp/ramdisk tmpfs mode=1777,size=8g

Here the device specified is ramdisk, the mount point is /tmp/ramdisk, the file system type is tmpfs, all permission are set for user, groups and other and the sticky bit is enabled, and the ramidisk’s size is defined by the size option.

References

No Comments

How to build a Debian packge in 3 steps

 Debian pakage

There are several ways of making a Debian package. In this article you will learn how to create it using equivs tools, to create a simple package (for example, as when you want to package a binary). Without more ado let’s see the procedure:

Requisites

You will need to install the tools to use, in particular:

aptitude install equivs

Procedure

As an example you will be packaging two scripts and an cron job in a .deb file. These are the steps:

  1. Create the template. To do so use the equivs-control command, which generates a base file that you can edit later by removing the comments to the options you want to use. To generate the template use this command:
$ equivs-control backups
  1. Edit the template, which in this example was called  backups. Fill in with the needed data for creating the package by removing the comment in the fields you want to edit:
### Commented entries have reasonable defaults.
### Uncomment to edit them.
# Source:
Section: miscD
Priority: optional
Homepage: www.lgallardo.com
Standards-Version: 3.9.2
Package: backups
Version: 1.1
Maintainer: Luis M. Gallardo D. <lgallard@gmail.com>
# Pre-Depends:
# Depends:
# Recommends:
# Suggests:
# Provides:
# Replaces:
Architecture: all
# Copyright:
# Changelog:
Readme: README.Debian
# Extra-Files:
Files: backup.sh /usr/local/bin/
 restore.sh /usr/local/bin/
 backups-cron /etc/cron.d/
Description: Backups scripts
 Scripts for backuping up files on Debian systems

Before you build thee package you must create the files backup.sh, restore.sh, backups-cron and README.debian, the latter to avoid equivs to use the generic README.

  1. Build the package. Just write this command:
$equivs-build backups

This will build a package called backups_1.1_all.deb.  In order to check the package’s info you can type the following:

$ dpkg -I backups_1.1_all.deb
 new debian package, version 2.0.
 size 2396 bytes: control archive=582 bytes.
 25 bytes, 1 lines conffiles 
 302 bytes, 12 lines control 
 322 bytes, 5 lines md5sums 
 Package: backups
 Version: 1.1
 Architecture: all
 Maintainer: Luis M. Gallardo D. <lgallard@gmail.com>
 Architecture: all
 Readme: README.debian
 Installed-Size: 42
 Section: misc
 Priority: optional
 Homepage: www.lgallardo.com
 Description: Backups scripts
 Scripts for backuping up files on Debian systems
That's it. You have build your first Debian package!

,

3 Comments

OpenLDAP course

Open LDAP

We already have the content of the OpenLDAP course. I share here the information for people who can be interested in, or if know somebofy who might be. Here the information (in Spanish):

Curso OpenLDAP

Tema  1 : Servidor de Directorios y LDAP

  • Conceptos básicos de LDAP
  • ¿Qué es un Directorio?
  • Estructura de Directorios
  • Nombres  Únicos (UN),
  • Entradas LDAP
  • Estructura de árbol de directorios,
  • ¿Qué hacer con un servidor de LDAP?
  • Servidor, cliente, utilitarios, librerías, resumen.

Tema 2:  Instalación y configuración de LDAP

  • Comenzando a trabajar con LDAP
  • Programas de LDAP
  • Distribuciones de LDAP
  • dependencias, configurando el server de LDAP
  • directivas, módulos, configuración de base de datos
  • Listas de Control de Acceso (ACL’s), arrancado y deteniendo los servicios.

Tema  3:  Usando OpenLDAP

  • Servidor OpenLDAP
  • operaciones, búsquedas
  • cargando de datos la base de datos
  • usando el  archivo LDIF, anatomía del archivo LDIF
  • estructurando el directorio y las unidades organizacionales
  • adicionando registros de usuarios, sistemas, grupos.
  • Trabajando con el archivo LDIF,  slapindex,slapcat, slapacl, spaldn, slapatuh, slappasswd, configurando ldap.conf.

Tema  4: Protegiendo mi Servidor OpenLDAP

  • Usando SSL/TLS, autentificación, encriptación
  • usando certificados, clientes con tls
  • trabajar con certificados: generar, actualizar, usarlos.

Tema  5:  Configuración Avanzada de OpenLDAP

  • Archivo slapd.conf
  • Creando e importando directorios
  • Rendimiento
  • Archivo DB_CONFIG
  • Trabajo con los registros logs
  • Modificando registros.

Tema  6:  Esquemas de LDAP

  • Introducción a los Esquemas
  • Definición de esquemas,
  • Clases, objetos,
  • Tipos de Objetos: Abstractos, Estructurales y auxiliares.

Tema 7:  Multiples Ditrectorios

  • Replicaciones, Syncrepl
  • Servidores maestros, servidores espejos (Shadow)
  • Configurando Proxy LDAP
  • Entonando las Caches.

Tema  8:  OpenLdap y la Web

  • Aplicativo LDAP-Aware
  • Apache, módulos de autenficación de Apache
  • phpldapadmin
  • Parámetros, navegando, administrando  los registros con la herramienta web.

More info at Avalon’s page

,

4 Comments

How to make big file system partions

Discos | Hard drives

Sometimes you’ll see on hard drives some inconsistencies with size, used value and the available space. The problem occurs when the operating system reports something different of what we locally we expect. For example:

# df -h | grep data

Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 788G 726G 23G 98% /var/data

If you do the math it should be 788 GB – 726 GB = 62 GB…but df (I mean Linux) reports there are 23 GB available. Where are the remaining 39 GB?

The issue is the available space. Available for whom? For the operating system, users, etc. But it turns out that on ext2, ext3 and ext4 file systems there is a  5%  of space reserved  by default to avoid the system to collapse, for example due to logs or data bases making it in-operating, so root can use that 5% to rescue it. Thus, checking the size of that partition we can see that  5% of 788 GB is 39.5 GB. Here is the difference.

Now, how can we use or take advantage of those extra GBs, because if a partition is used just for data those 5% for the operating system makes no sense except for the root /  or  /var partitions,. There are two ways:

  1. When the partition’s file system is created you can use the  -m option in the  mkfs.ext[2,3,4] command. example:
    mkfs.ext3 -m 0 /dev/sdb1
  2. If the file system was already created, you can use the  -m option with the tune2fs command. But here it’s important to umount the partition first to avoid data loss. Example:
# umount /var/data

# tune2fs -m 0 /dev/sdb1

tune2fs 1.41.12 (17-May-2010)
Setting reserved blocks percentage to 0% (0 blocks)

# mount /var/data

Then check the available space one more time:

# df -h | grep data

Filesystem Size Used Avail Use% Mounted o

/dev/sdb1 788G 726G 63G 93% /var/data

Now  the space available correspond to what we logically expected…by the way, how we can check the reserved space without using df? There are to ways:

  1. Using dumpe2fs:
    # dumpe2fs -h /dev/sdb1 | grep Reserved
    
    dumpe2fs 1.41.12 (17-May-2010)
    Reserved block count: 0
  2. Using  tune2fs:
    # tune2fs -l /dev/sdb1 | grep Reserved Reserved block count: 0

No Comments

Daemontools or how to relaunch a process if it dies

building-24220_150

Maybe you have been in the situation where a process (program or service) in the system dies or ends abruptly and needs to be relaunched  no matter what. You can try to monitor the process from time to time and restart it if it’s not found, but it could be a little complicated because you have to make a cron rule to check the process existence, filter the process, etc. What if there would be a way to relaunch a process if it dies?…There is a way, it’s called daemontools which basically scans the process and relaunches it if  it’s not detected.

Here I’ll show you how to install and configure this tool on Linux.

Installing daemontools

On Debian you can install daemontools as root by typing this:

root@raspberrypi: # aptitude install daemontools-run daemontools

For Debian spin-off like Ubuntu would be the same. On Red Hat and alike you must check if there is a package for this tool.

First execution

After installing the package a called to /usr/bin/svscanboot is created (you can check it in the /etc/init/svscan.conf file) and it will be executed at rebooting the system. If you don’t want to restart your system you can execute svscanboot manually:

nohup /usr/bin/svscanboot &

Setting daemontools

You have to make a directory for the service (program) you want to monitor. In this example I would use qbittorrent-nox, a bittorrent client that runs on the background (nox = no for X environment):

root@raspberrypi:~# mkdir /etc/service/qbittorrent-nox

Then you have to write and script that start the process. It must be called “run“. Use your preferred text editor, for instance vi:

root@raspberrypi:~# vi /etc/service/qbittorrent-nox/run

And add the call to the program. In this case I wanted to launch qbitorrent-nox as the user pi, so I invoked it using sudo:

#!/bin/sh

sudo -u pi qbittorrent-nox

Finally change permissions to make it executable:

root@raspberrypi:~# chmod +x /etc/service/qbittorrent-nox/run

Checking the process with ps

You can check if the process is running the using ps command and filtering the output with grep:

root@raspberrypi:~# ps ax | grep qbit

3064 ? S 0:00 supervise qbittorrent-nox
3068 ? S 0:00 sudo -u pi qbittorrent-nox

3080 ? Sl 13:09 qbittorrent-nox

9926 pts/0 S+ 0:00 grep qbit

But there’s a better way to check  if the process is running, using daemontools. By the way, daemon-tools means tools for handling daemons (programs or services).

Checking the process with daemontools

If you want to check if the process is running and how long it had been up, use the svtat command passing the service directory, as show next:

root@raspberrypi:~# svstat /etc/service/qbittorrent-nox
 /etc/service/qbittorrent-nox: up (pid 3066) 205846 seconds

In this case, my qbittorrent-nox process (program/service) has been running for almost two days and a half.

Stoping the scan

If you need to stop scanning the process,  for instance if you need to stop it for a while to change a setting, use the svc command with the following option:

root@raspberrypi:~# svc -d /etc/service/qbittorrent-nox

After this, check it one more time:

root@raspberrypi:~# svstat /etc/service/qbittorrent-nox
 /etc/service/qbittorrent-nox: down 2 seconds, normally up

Now the process won’t be checked to be relaunched if it stops or dies.

Restarting the scan

In order to restart the scan, use the svc command as followed:

root@raspberrypi:~# svc -u /etc/service/qbittorrent-nox

One more time, check whether it’s running with svstat:

root@raspberrypi:~# svstat /etc/service/qbittorrent-nox
 /etc/service/qbittorrent-nox: up (pid 12805) 1 seconds

Reference: daemontoolsl

No Comments