Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I've a script that runs every 30m and check if /mnt/controlurg is mounted. If not, it tries to mount it and get some files from it (it's a Windows drive). Before 12.04 I didn't had problems but now when the script can't mount (for any reason) the remote drive the mount command don't end and keeps as a background process. And even worst, a new zombie background mount process is created every 30m and the CPU Load Average is getting high (now is 44%!!).

Checking for running processes I get multiple entries like that:

root     29458 29420  0 08:35 ?        00:00:00 mount /mnt/controlurg
root     29459 29458  0 08:35 ?        00:00:00 /sbin/mount.cifs //controlurg/c$ /mnt/controlurg -o rw,noauto,user=root,passwd=example,utf8
  • How can I kill that processes? "kill -9 29459" doesn't work.
  • Why these processes don't timeout? How can I kill this failed mounts automatically?

The interesting fragment of /opt/scripts/sftpcont.shl:

cat $SCRIPT/computers.dat | while read line
echo `date "+%Y/%m/%d %H:%M:%S"` ": Copying to ${line} with samba"
isalive=`ping -q -c1 $line| grep "1 received" |wc -l`
if [ $isalive!= "0" ]
  mount /mnt/$line
  rm /mnt/$linea/contingenciasap/*
  cp $SCRIPT/fitxers/ /mnt/$line/contingenciasap
  umount /mnt/$line


share|improve this question

1 Answer 1

It would be great if you show your script. But anyway, you have to use exit command like:

mount <partition> /mnt/controlurg || exit 1

This command just will stop running script. You can show some message(or write to log file) like:

mount <partition> /mnt/controlurg || eval 'echo "Error mounting partition" 1>&2; exit 1'

mount <partition> /mnt/controlurg || eval 'echo "Error mounting partition\n" >> mount.log; exit 1'

To kill all processes use killall command.

share|improve this answer
The killall command (killall mount) only kill the processes "mount /mnt/controlurg", but not the /sbin/mount.cifs ... So the CPU Load keeps getting high. I tried kill -9, killall... restart samba, ... and the background processes remain :( I've added the script in the post. I can't use the "|| exit 1" because I don't want to stop the script when a mount fails, the script have to keep going. – Dimas Jul 19 '12 at 9:38
Ok. Than you have to use break command or continue. – Victor K Jul 19 '12 at 14:19
Probably, continue is what you are searching for(read another line and try mount it). Use : ||continue – Victor K Jul 19 '12 at 14:30
Oh! Sorry I forgot. Try killall /sbin/mount.cifs. Hope it help you. – Victor K Jul 19 '12 at 18:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.