Debian 中 cmatrix 更新后的重启方法
一、前台直接重启
- 如果正在终端中运行 cmatrix,按下Ctrl + C结束当前进程,然后重新输入命令启动即可。
- 常用启动示例:
- 基本效果:cmatrix
- 全屏:cmatrix -fs
- 自定义颜色:先设置环境变量再启动,例如
export cmatrix_colors=‘0;31:1;32:2;33:3;34:4;35:5;36:6;37’
cmatrix
以上命令均为前台运行,更新后这样重启最为直接。
二、作为 systemd 服务运行时的重启
- 若你之前已将 cmatrix 配置为系统服务(如创建了 /etc/systemd/system/cmatrix.service),更新后可用以下命令重启服务:
- 重新加载 systemd 配置(更新后建议执行一次):sudo systemctl daemon-reload
- 重启服务:sudo systemctl restart cmatrix.service
- 查看状态:sudo systemctl status cmatrix.service
这种方式适合在后台持续运行或开机自启的场景。
三、会话保活与后台运行
- 使用终端复用器(推荐):
- 启动会话:tmux new -s matrix 或 screen -S matrix
- 在会话中运行:cmatrix
- 分离会话:Ctrl + B 再按 D(tmux)或 Ctrl + A 再按 D(screen)
- 重新连接:tmux attach -t matrix 或 screen -r matrix
- 需要停止时,先重新连接会话,再按Ctrl + C结束 cmatrix。
- 使用 nohup 后台运行:
- 启动:nohup cmatrix &
- 查看输出:tail -f nohup.out
- 停止:获取进程号后结束,例如 kill $(pgrep cmatrix)。
以上方法可在更新后快速恢复运行,并避免关闭终端导致进程中断。