LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Finding out which process calls a program/script ("/sbin/usbmod") (https://www.linuxquestions.org/questions/linux-software-2/finding-out-which-process-calls-a-program-script-sbin-usbmod-808852/)

JZL240I-U 05-19-2010 09:31 AM

Finding out which process calls a program/script ("/sbin/usbmod")
 
SuSE 11.2, KDE 4.2 after logging in to runlevel 5:

I have a process which is calling every 5 seconds /sbin/usbmod (which doesn't exist, hence I get lots of errors when I go to the screen with the boot messages). I want to know which process does the calling. How can I find out?

Valery Reznic 05-20-2010 01:53 AM

Quote:

Originally Posted by JZL240I-U (Post 3974175)
SuSE 11.2, KDE 4.2 after logging in to runlevel 5:

I have a process which is calling every 5 seconds /sbin/usbmod (which doesn't exist, hence I get lots of errors when I go to the screen with the boot messages). I want to know which process does the calling. How can I find out?

Create script /sbin/usbmod:
Code:

#!/bin/sh
echo $PPID >> /tmp/usbmod_caller


Shadow_7 05-20-2010 02:49 PM

ps -Al

(when it's running)

otherwise the long and slow way...

$ egrep -r -i "usbmod" /etc/*

Might be a daemon, or cron, or other thing. If it doesn't exist, you could always create a stub to stop the messages. Although a stub might also cause unknown issues as well.

Code:

#!/bin/sh
exit 0

Or just find it and install it.

$ apt-file find /sbin/usbmod
(or whatever the SuSE equivalent is.)

JZL240I-U 05-21-2010 01:46 AM

@ Valery Reznic Worked like a charm, thanks a load. I created the script just like you suggested and made it executable. Since the job runs every 5 seconds I had not even to pause to get the result(s). Via "ps ax | grep <PID>" I got the culprit: /sbin/HWActivator. That is (possibly) needed for my WLAN USB-connector, which I got too recently to be sure about its being really needed. Its intended purpose is to switch the USB-stick from memory to modem state.

@ Shadow_7 It runs for a very brief moment every 5 seconds, I'm not sure how much luck I'd need to hit the same time slot by hand ;). For what it is, see above. With "stub" you mean an empty job which does nothing but prevent the error message, I presume. Well, I found usbmod but I don't really understand what it does (in particular how it assigns its option "$1" a value):
Code:

#! /bin/bash

if [ "$1" == "remove" ]
then
#    echo "remove pl2303"
      if [ "$(/sbin/lsmod |grep pl2303)" != "" ]
      then
            /sbin/rmmod pl2303
      fi
elif [ "$1" == "update" ]
then
      if [ "$(/sbin/lsmod |grep option)" != "" ]
      then
            /sbin/rmmod option
      fi
      if [ "$(/sbin/lsmod |grep pl2303)" != "" ]
      then
            /sbin/rmmod pl2303
      fi
      if [ "$(/sbin/lsmod |grep usbserial)" != "" ]
      then
            /sbin/rmmod usbserial
      fi

      /sbin/modprobe usbserial vendor=0x12d1 product=$2 
else
#    echo "modprobe usb-storage"
      if [ "$(/sbin/lsmod |grep usb-storage)" == "" ]
      then
            /sbin/modprobe usb-storage
      fi
fi


JZL240I-U 06-01-2010 06:42 AM

Well, HWActivator is not needed (anymore, at least not when running SuSE 11.2). Thanks every one for helping.


All times are GMT -5. The time now is 12:00 AM.