Linux – Identify Process Starting at Startup

autostartlinuxUbuntu

I've got a problem:

A while ago, I installed a piece of software called wii-u-gc-adapter, and when I run it, I can plug my GameCube controller in to my Linux machine desktop computer to play games. This works great.

I must have taken some advice at some point in time to put somewhere in my computer an instruction to run this process at startup.

I bring this up because when I turn my computer off, it hangs for one minute 30 seconds waiting for this process to end.

When I run ./wii-u-gc-adapter myself, I then manually kill it. But at some point in installing it, I told my system to run it.

The program is listed in usr/local/bin, which doesn't surprise me.

Here is the end of my $pstree

        ├─whoopsie───2*[{whoopsie}]
        ├─wii-u-gc-adapte───2*[{wii-u-gc-adapte}]
        ├─wpa_supplicant
        └─xdg-permission-───2*[{xdg-permission-}]

In htop I see the following when I filter for wii:

htop filtered for wii

When I shutdown my computer, I have to wait for one minute 30 seconds, and when I press F2 I see this message:

A stop job is running for Wii U Gamecube Adapter

I'd like to clean up this loose end. I usually document what I do when I modify a file, but I don't think I did here, so I'm having a hard time finding where I made a change that causes this program to run on startup.

[Some progress here – edit 1]

~$ ps j 1045
   PPID     PID    PGID     SID TTY        TPGID STAT   UID   TIME COMMAND
      1    1045    1045    1045 ?             -1 Ssl      0   0:00 /usr/local/bin/wii-u-gc-adapter

So the parent process of 1045 is PPID 1, i.e. it looks like someone told systemd to start this process. I would like to take this process off that list.

[ more progress here]

Found a gamecube.service file by going to /etc and using ag to search for it.

systemd/system/gamecube.service
2:Description=Wii U Gamecube Adapter
8:ExecStart=/usr/local/bin/wii-u-gc-adapter

I'd like to completely remove this service.
[Third edit] I am following this answer: https://superuser.com/a/936976

[Fourth edit] Following the procedure from superuser, after finding that the parent process was indeed systemd with ps j, this problem is now resolved.

Best Answer

Solution:

  1. Find process name in pstree
  2. Find process in htop, get PID from there
  3. Use command ~$ ps j [PID] to find the PID of the parent process
  4. If the PID is 1, then it is being started by systemd
  5. If it is started by systemd, use this answer along with the information you got from step 1 and step 2 to totally remove the process from systemd's list of what to run on start up.
Related Question