linux相关指令
sudo yum update sudo yum install -y wget # CentOS 7 及以下 sudo dnf install -y wget # CentOS 8+ aarch64架构 nohup ./your_program > output.log 2>&1 & nohup ./Demo1 & jobs -l # 查看后台任务(仅当前终端有效)nohup ps aux | grep your_program # 全局查看进程jobs ps aux | grep demo #安装nginx yum install nginx 启动Nginx服务并设置开机自启 sudo systemctl start nginx sudo systemctl enable nginx 检查服务状态 sudo systemctl status nginx 访问默认欢迎页面 curl http://localhost 默认网站根目录: /usr/share/nginx/html 修改配置后,验证配置是否正确: sudo nginx -t 重新加载Nginx配置(无需重启服务) sudo systemctl reload nginx 配置文件 //etc/nginx/nginx.conf 下载 wget https://nginx.org/download/nginx-1.25.1.tar.gz 解压缩 .tar ·tar -cvf file.tar dir/ tar -xvf file.tar .tar.gz tar -zcvf file.tar.gz dir/ tar -zxvf file.tar.gz .tar.bz2 tar -jcvf file.tar.bz2 dir/ tar -jxvf file.tar.bz2 .tar.xz tar -Jcvf file.tar.xz dir/ tar -Jxvf file.tar.xz .zip zip -r file.zip dir/ unzip file.zip .7z 7z a file.7z dir/ 7z x file.7z 创建 Systemd 服务文件 sudo nano /etc/systemd/system/myapp.service myapp.service创建服务文件 [[Unit] Description=My Python Application After=network.target # 依赖网络服务启动后再启动本服务 [Service] User=appuser # 运行服务的用户(避免使用 root) Group=appuser # 运行服务的用户组 WorkingDirectory=/opt/myapp # 应用工作目录 ExecStart=nohup home/test/out5/Demo1 & # 启动命令(绝对路径) Restart=always # 服务崩溃后自动重启 [Install] WantedBy=multi-user.target # 系统启动时自动启动 启动服务 sudo systemctl daemon-reload sudo systemctl start myapp sudo systemctl enable myapp # 列出所有正在运行的服务(包括已启用和未启用) systemctl list-units --type=service --state=running # 列出所有服务(无论是否正在运行) systemctl list-unit-files --type=service # 查看单个服务的状态(如 nginx) systemctl status nginx.service
#最终的myapp.service [Unit] Description=My Python Application After=network.target [Service] User=root Group=root ExecStart=/home/test/out5/out/Demo1 Restart=always [Install] WantedBy=multi-user.target
天道酬勤 循序渐进 技压群雄
浙公网安备 33010602011771号