0

I have root access to a Linux system and need to log processes without installing any additional software, using only built-in tools like top. However, I want the process to run in the background continuously until I manually stop it, whereas top which only shows real-time data.

Here’s what I need:

  1. When the command is executed, it should capture the initial state of all running processes.

  2. If any new process spawns or an existing process terminates, the log should capture the timestamp, the command, and user info for those changes.

  3. When I stop the logging, it should also record the final state of the processes at that moment.

How can I achieve this using pre-installed Linux tools like top?

5
  • The requirements don't make sense. you may have top installed but it certainly isn't required in a minimal system. There is no concept of built-in Linux tools. Commented Sep 28, 2024 at 16:20
  • "built-in"... Built in to what, exactly? On Ubuntu, top is in the procps package, which is marked Priority: required, so it likely comes installed by default. But that might be more because of ps itself than top, and there's no guarantee it comes installed by default on other distributions. Similarly for other tools, it might depend on the distribution which ones come installed by default and which ones don't. Sure, you probably get something like the GNU coreutils on most "big" GNU/Linux distributions, but e.g. on Busybox-based ones you probably don't. So, which distro are you on? Commented Sep 28, 2024 at 19:55
  • I am using SUSE Linux Enterprise. Is it possible to log processes as described using the topcommand? Can I also capture short-lived processes. Commented Sep 28, 2024 at 20:21
  • Are you allowed to create bash scripts or compile C programs? Detect new process creation instantly in linux has (a) the answer with how to use a socket with NETLINK_CONNECTOR which could be used to create a C program (b) A link to the execsnoop script from perf-tools. Commented Sep 29, 2024 at 11:53
  • I can create bash scripts or compile C programs. Commented Sep 30, 2024 at 5:32

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.