xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

How to use Linux command to find out the background process All In One

How to use Linux command to find out the background process All In One

Linux command check background process

jobs

$ jobs
[1]+  运行中               sudo python3 /home/pi/OLED_Stats/stats.py &

bg

$ bg %1

$ pi@raspberrypi:~ $ bg --help
bg: bg [任务声明 ...]
    移动任务至后台。

    将 JOB_SPEC 标识的任务放至后台,就像它们
    是带 `&' 启动的一样。如果 JOB_SPEC 不存在,shell 观念中的
    当前任务将会被使用。

    退出状态:
    返回成功除非任务管理没有启用或者错误发生。
pi@raspberrypi:~ $ 

ps

$ sudo ps -aux | less

$ sudo ps -r
    PID TTY      STAT   TIME COMMAND
  47556 tty1     R+     0:00 top -bn1
  47560 pts/0    R+     0:00 ps -r
$ sudo ps T
    PID TTY      STAT   TIME COMMAND
  35505 pts/0    Ss     0:00 -bash
  35754 pts/0    S      0:00 sudo python3 /home/pi/OLED_Stats/stats.py
  35762 pts/0    S      0:22 python3 /home/pi/OLED_Stats/stats.py
  47945 pts/0    S+     0:00 sudo ps T
  47946 pts/0    R+     0:00 ps T
pi@raspberrypi:~ $ 

https://www.cyberciti.biz/faq/find-out-what-processes-are-running-in-the-background-on-linux/

??? ps

https://unix.stackexchange.com/questions/701938/how-do-i-list-all-background-processes

demos

$ cat .profile 
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
	. "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

echo "每次登录自动执行脚本 ✅"
bash /home/pi/Desktop/ip-program.sh

echo "开启SSD1306 OLED 🖥️ 🌡️"
sudo python3 /home/pi/OLED_Stats/stats.py &

$ ps -ef

$ ps -ef | grep py

image

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2023-05-08 14:46  xgqfrms  阅读(23)  评论(1编辑  收藏  举报