一、下载
移步下载区下载centos平台工具软件。
二、上传文件至Centos
使用WinSCP登录Centos,新建一文件夹,命名为:afte,上传文件至afte文件夹中。
三、临时运行
(1)使用putty连接至Centos,cd命令到afte文件夹
(2)赋予执行权限
sudo chmod 777 afte.Service
(3)执行
./afte.Service
如上图,出现Online信息,表示已与服务器取得联系,同时软件根目录下出现lwd.txt文本文件,其中记录的是19位数字字符串,下称为客户端ID,用于标识当前所运行的PC。当在新的PC中运行本工具软件时,必须删除。

(4)添加客户端ID到微信小程序进行在线管理
本工具软件使用微信小程序进行在线管理,快捷方便。
参考:绑定客户端ID到微信小程序进行在线管理
四、作为服务运行
把本工具软件注册为系统服务,Linux系统启动后,本工具自动启动,实现无人值守服务。
(1)赋予执行权限
参考以上第三步骤,赋予afte.Service执行权限
(2)cd 到system位置
cd /etc/systemd/system
(3)创建afte.service文件
sudo nano afte.service
(4)输入内容
[Unit]
Description=afte service
After=network.target
[Service]
Type=notify
ExecStart=/home/lwdred/afte/afte.Service
[Install]
WantedBy=multi-user.target
快捷键Ctro+字母o后输入文件名:afte.service
快捷键Ctro+字母x后保存文件并退出编辑模式。
(5)启动服务
根据需要适当执行以下服务命令。
//重新挂载服务
sudo systemctl daemon-reload
//启动服务
sudo systemctl start afte.service
//停止
sudo systemctl stop afte.service
//查看服务状态
sudo systemctl status afte.service
//设置开机启动
sudo systemctl enable afte.service
//查看服务是否是自启动
systemctl is-enabled afte.service
(6)添加客户端ID到微信小程序进行在线管理
本工具软件使用微信小程序进行在线管理,快捷方便。
参考:绑定客户端ID到微信小程序进行在线管理
五、常见问题
(1)问题1,如下提示:
绝大部分原因是开启了SELinux模式也就是增强型Linux,导致没有执行权限。
如提示:status=203/EXEC
查看日志,输入:sudo tail -f /var/log/messages
明显看到有:Permission denied字样。
8月 12 13:50:45 lwd sudo[12840]: pam_unix(sudo:session): session closed for use>
8月 12 13:50:45 lwd dbus-daemon[886]: [system] Activating service name='org.fed>
8月 12 13:50:47 lwd dbus-daemon[886]: [system] Successfully activated service '>
8月 12 13:50:48 lwd setroubleshoot[12848]: SELinux is preventing /usr/lib/syste>
8月 12 13:50:48 lwd platform-python[12848]: SELinux is preventing /usr/lib/syst>
解决方法:SELinux赋予权限
sudo chcon -t shell_exec_t /home/lwdred/autorun/net6/afte.Service
查看SELinux模式:
getenforce
1、enforcing:强制模式
2、permissive:宽容模式
3、disabled:关闭 SELinux。
附送几个SELinux相关命令
ls -Z file ---- 查看file的SELinux属性
setenfore ----- 设置SELinux工作模式
sestatus ----- 查看SELinux状态
所有问题解答