Ubuntu: How to Force a Silent Cron

Posted on Tuesday, January 4, 2011 by Craig Lotter

By default, cron actions that produce output generates emails that get sent to the system administrator. If we don’t particularly want this behaviour, we need to terminate our function calls with a specific character sequence, which looks as follows:

5 * * * * /usr/mine/script > /dev/null 2>&1

The first part of the statement sends the output to the “bit bucket” (> /dev/null) which is basically the same as throwing it away. The second part of the call (2>&1) forces all generated stderror error messages to follow the stdout messages, which in this case we’ve already pointed towards the “bit bucket”.

Simple, and effective, if you don’t want to be bothered by a whole lot of non-critical cron jobs!

viaUbuntu: How to Force a Silent Cron | The Rugged Rock of Craig.

I love nagios it’s the perfect way to monitor linux. Monitoring command can be written in almost any language: nagios expects a exit code and a exit string and it works. I write most of my plugins in bash shell. Here is a generic plugin template:


# Sanity check
if [ $# -ne 2 ]; then
echo « Usage: $0 commandline1 commandline2″


if grep -q « succeeded! » <<< $COMMAND; then
echo "OK - $1 $2 working"
exit ${E_SUCCESS}
echo "CRITICAL - $1 $2 not working"
exit ${E_CRITICAL}

© 2010, Joseph Griffiths. All rights reserved.

Template for Generic Nagios Plugin | blog.jgriffiths.org.

Being Nice on a Linux Box – Process priority with 'nice' & 'renice' – Nimal's Weblog.

Problem (I had): Wanted to run a VirtualBox on a RHEL 4.7 Linux server which is shared by someothers. But as some other processes took more CPU, the VirtualBox performance was bad. So I wanted to increase the priority given to VirtualBox.

Solution (I found): VirtualBox can be given higher priority using nice command. Also renice command can be used to change the priority of a running process, which will also be useful.

nice -10 VBoxHeadless

Gives the VBoxHeadless process 1.5 times priority than the normal process, calculated as (20 – -10)/20 = 1.5

nice -20 make

Executes make at maximum priority.

renice +20 2222

Changes the priority of process 2222 to +20 (minimum priority).

renice -10 -p 13013

Changes the priority of a running process by specifying its process ID, where priority can be,

1 to 20 :Â Runs the specified processes slower than the base priority.
0 :Â Sets priority of the specified processes to the base scheduling priority.
-20 to -1 :Â Runs the specified processes quicker than the base priority.

Build cross-compiled kernel debian package

Par Jérôme Pouiller le vendredi, octobre 29 2010, 09:37 – Lien permanent

As you may know, you have juste to add options ARCH and if necessary CROSS_COMPILE to command line:

make ARCH=powerpc CROSS_COMPILE=ppc-linux-gnu- XXX_defconfig

make ARCH=powerpc CROSS_COMPILE=ppc-linux-gnu- XImage

My primary concern is to compile an x86 32bits kernel in 64bits environement. So my compilation line is:

make ARCH=i386 i386_defconfig

make ARCH=i386 bzImage

As you also may know, rule deb-pkg of kernel Makefile is able to create a debian package. You should use fakeroot to be able to create package with a non-root user:

fakeroot make deb-pkg

Nevertheless, it will always create a package for current architecture. So this line will create a package for powerpc:

fakeroot make ARCH=powerpc CROSS_COMPILE=ppc-linux-gnu- deb-pkg

To correct this behavior, you can use DEB_HOST_ARCH variable:

fakeroot make DEB_HOST_ARCH=powerpc ARCH=powerpc CROSS_COMPILE=ppc-linux-gnu- deb-pkg

To summary, to quickly create an x86 32bits kernel debian package in 64bits environement. I do:

mkdir build

make ARCH=i386 O=build i386_defconfig

fakeroot make -j4 DEB_HOST_ARCH=i386 ARCH=i386 O=build deb-pkg

viaBuild cross-compiled kernel debian package – Sysmic.org.

A – search for rootkits

B – more detailed investigation

C – more trails

D – remove it!

E – refresh system

F – Todo

G – Infos

Start with these tools:



A – search for rootkits


Checking `ifconfig’… INFECTED

Checking `pstree’… INFECTED

Searching for t0rn’s v8 defaults… Possible t0rn v8 \(or variation\) rootkit installed

Searching for Showtee… Warning: Possible Showtee Rootkit installed

Searching for Romanian rootkit… /usr/include/file.h /usr/include/proc.h

Checking `bindshell’… INFECTED (PORTS: 465)

Checking `lkm’… You have 1 process hidden for ps command

Warning: Possible LKM Trojan installed

Checking `sniffer’… eth0: PF_PACKET(/usr/sbin/iptotal)



Rootkit Hunter found some bad or unknown hashes. This can be happen due replaced

binaries or updated packages (which give other hashes). Be sure your hashes are

fully updated (rkhunter –update). If you’re in doubt about these hashes, contact

the author (fill in the contact form).


Rootkit ‘SHV4′… [ Warning! ]


Found parts of this rootkit/trojan by checking the default files and directories

Please inspect the available files, by running this check with the parameter

–createlogfile and check the log file (current file: /var/log/rkhunter.log).


* Application version scan

- GnuPG 1.2.4 [ Vulnerable ]

- OpenSSL 0.9.7a [ Vulnerable ]

- PHP 4.3.9-1 [ Unknown ]

- PHP 4.3.9-1 [ Unknown ]

- Procmail MTA 3.22 [ OK ]

- OpenSSH 3.8.1p1 [ OK ]

B – more detailed investigation

#> lsof -i

3 12481 root 3u IPv4 139597 TCP *:2345 (LISTEN)

# telnet localhost 2345


Connected to localhost.

Escape character is ‘^]’.


#> cat /proc/13066/cmdline


# which ttyload


# ls -l /sbin/ttyload

-rwxr-xr-x 1 122 114 212747 Jul 16 13:37 /sbin/ttyload

# kill 12481

# rm /sbin/ttyload

rm: remove write-protected regular file `/sbin/ttyload’? y

rm: cannot remove `/sbin/ttyload’: Operation not permitted

# last

bd pts/0 pd950ea5a.dip.t- Tue Nov 30 19:05 still logged in

reboot system boot 2.4.21-pre5-1um Tue Nov 30 19:04 (00:38)

bd pts/5 pd950ea5a.dip.t- Tue Nov 30 17:52 – down (00:46)

bd pts/0 pd950ea5a.dip.t- Tue Nov 30 17:51 – down (00:47)

bd pts/4 pd950ea5a.dip.t- Tue Nov 30 16:52 – down (01:46)

natraj pts/2 pd9eb7a77.dip0.t Tue Nov 30 14:38 – 18:00 (03:21)

bd pts/1 pd950ea5a.dip.t- Tue Nov 30 14:38 – down (04:00)

bd pts/0 pd950ea5a.dip.t- Tue Nov 30 14:32 – 17:49 (03:17)

reboot system boot 2.4.21-pre5-1um Tue Nov 30 14:31 (04:07)

reboot system boot 2.4.21-pre5-1um Tue Nov 30 14:24 (04:14)

joko pts/2 pd950ea5a.dip.t- Tue Nov 30 14:02 – crash (00:21)

natraj pts/0 pd9eb7a77.dip0.t Tue Nov 30 11:28 – crash (02:56)

natraj pts/0 pd9eb6304.dip0.t Mon Nov 29 14:51 – 17:57 (03:06)

bd pts/1 p54802510.dip.t- Mon Nov 29 09:59 – 13:49 (03:50)

bd pts/0 p54802510.dip.t- Mon Nov 29 08:16 – 10:25 (02:09)

reboot system boot 2.4.21-pre5-1um Mon Nov 29 08:10 (1+10:28)

wtmp begins Sun Nov 28 06:37:56 2004

C – more trails

# nano /root/.bash_history

export TERM=vt100

vi /etc/passwd

passswd bin

passwd bin

# find / -uid 122









find: /proc/25248/fd/4: No such file or directory


# cat /proc/25248/cmdline

xukay:/home/uml/quepasa/rootfs/mnt# find . -uid 122




















# find / -gid 114














find: /proc/1014/fd/4: No such file or directory

D – remove it!

# chattr -sia /usr/lib/libsh

# rm -r /usr/lib/libsh/

# chattr -sia /lib/libsh.so

# rm -r /lib/libsh.so


E – refresh system

find @ http://packages.debian.org/

# apt-get install findutils


# apt-get install fileutils coreutils

# cd /var/cache/apt/archives/

root@quepasa:/var/cache/apt/archives# dpkg -i coreutils_5.2.1-2_i386.deb


# apt-get install procps


# apt-get install lsof


# apt-get install dpkg


# apt-get install psmisc


# apt-get install net-tools

# apt-get install netkit-inetd

# apt-get install textutils

# apt-get install shellutils

# apt-get install qpopper

# apt-get install vsftpd

# apt-get install rsync

# apt-get install uw-imapd-ssl

# apt-get install libssl0.9.7

# apt-get install ssh

# apt-get install cron

# apt-get install inn

# apt-get install util-linux

viaQuepasaSHV4 « Pad « netfrag.org.

Variables en shell Bash

Manipulation de variables simples

var=val ou var= »a b » affectation de la variable « var »

$var ou ${var} contenu de la variable « var »

${#var} longueur de la variable « var »

export var ou declare -x var exportation de la variable « var » vers les shells fils

set affichage de l’ensemble des variables définies dans le shell

unset var suppression de la variable « var »


tab[0]=val affectation du premier enregistrement du tableau « tab »

${tab[0]} ou $tab contenu du premier enregistrement du tableau « tab »

${tab[11]} contenu du douzième enregistrement du tableau « tab »

${tab[*]} ensemble des enregistrements du tableau « tab »

${#tab[11]} longueur du douzième enregistrement du tableau « tab »

${#tab[*]} nombre d’enregistrements du tableau « tab »

Paramètres positionnels et arguments

$0 nom du script

$1 $2 … ${10} paramètres positionnels (1, 2 et 10)

$# nombre de paramètres positionnels

$* ou $@ ensemble des paramètres positionnels, équivalant à $1 $2 … ${n}

« $* » ensemble des paramètres positionnels, équivalant à « $1 $2 … ${n} »

« $@ » ensemble des paramètres positionnels, équivalant à « $1″ « $2″ … « ${n} »

Variables spéciales

$$ PID du shell courant

$! PID du dernier travail lancé en arrière plan

$? code retour de la dernière commande

Variables d’environnement

$HOME chemin du répertoire personnel de l’utilisateur

$OLDPWD chemin du répertoire précédent

$PATH liste des chemins de recherche des commandes exécutables

$PPID PID du processus père du shell

$PS1 invite principale du shell

$PS2 invite secondaire du shell

$PS3 invite de la structure shell « select »

$PS4 invite de l’option shell de débogage « xtrace »

$PWD chemin du répertoire courant

$RANDOM nombre entier aléatoire compris entre 0 et 32767

$REPLY variable par défaut de la commande « read » et de la structure shell « select »

$SECONDS nombre de secondes écoulées depuis le lancement du shell

viaVariables en shell Bash.

How to debug or test cron script

If your simple cron script (/etc/cron.daily, etc/cron.hourly etc) does not run as expected, do the following:

1. be sure to have ‘#!/bin/sh’ as the first line

2. make sure the script’s name does not contains ‘.’. for example, you should rename ‘yourscript.sh’ to ‘yourscript’.

3. use absolute path if you need to read/write files in the script

4. try run the script in the shell to make sure there is no obvious problem

5. ‘run-parts –test /etc/cron.hourly/’ will tell you what scripts will run, you should see your script in the list

6. next try to run it like cron does, for example:

cd / && run-parts –report /etc/cron.hourly

7. cron uses syslog for logging. Check your syslog config file ( /etc/syslog.conf) to see where the log is, and check the log for errors.

viaX.Y.Z: How to debug or test cron script.

zssh, ZModem ssh, an alternative way to ssh and scp? To perform file transfer and ssh in ordinary way you need ssh and scp.

Conventional way, let say you want to download certain files from a root directory of a server which you do not sure where is the actual location.

First you login to the server, search for the location, then open another terminal and uses scp to download the file.

Assume server name : shell.org , Login name: mysurface

ssh mysurface@shell.org

After surfing the directories, I discovered that the file you wanna download is at /var/www/ctw/popup/.htaccess

So, I open a new terminal, and uses scp to download the file to current directory.

scp mysurface@shell.org:/var/www/ctw/popup/.htaccess .

zssh way,

First step is the same

zssh mysurface@shell.org

After locate the file, simply do this

sz .htaccess

[sz means send ]

Without need to open a new terminal, press control shift 2 or simply known as [^@] to enter zssh mode. In this mode, you are like in your local machine, change directory to the place you wanna store the file, and then start receive the file.


Done! After that you can return to your ssh mode by control d [^d] or simple type exit or quit.

The upload works the same way, but you do not need to type rz at remote server, it will do it for you automatically.

Press ^@ to enter zssh mode, search the file to upload, then

sz dummy.cpp

Requirement: Both remote server and local host need to install sz and rz

viazssh, interactive file transfer wrapper for ssh » Linux by Examples.