linux常用命令全集上像服务一样启动python程序,开机自动启动,能够start,stop,restart,status等?

您的浏览器已经禁用了脚本,这会严重影响您正常使用本站的功能,请开启!
当前位置: &
& systemctl
systemctl命令
systemctl命令是系统服务管理器指令,它实际上将
这两个命令组合到一起。
使某服务自动启动
chkconfig --level 3
httpd.service
使某服务不自动启动
chkconfig --level 3 httpd off
systemctl disable httpd.service
检查服务状态
service httpd status
systemctl status&httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active)
显示所有已启动的服务
chkconfig --list
systemctl list-units --=service
启动某服务
service httpd start
systemctl start httpd.service
停止某服务
service httpd stop
systemctl stop httpd.service
重启某服务
service httpd restart
systemctl restart httpd.service
1.启动nfs服务
systemctl&start&nfs-server.service
2.设置开机自启动
systemctl&enable&nfs-server.service
3.停止开机自启动
systemctl&disable&nfs-server.service
4.查看服务当前状态
systemctl&status&nfs-server.service
5.重新启动某服务
systemctl&restart&nfs-server.service
6.查看所有已启动的服务
systemctl&list&-units&--type=service
开启防火墙22端口
&-I&INPUT&-p&tcp&--dport&22&-j&
如果仍然有问题,就可能是SELinux导致的
关闭SElinux:
修改/etc/selinux/config文件中的SELINUX=&&为disabled,然后重启。
彻底关闭防火墙:
&systemctl&status firewalld.service
sudo&systemctl&stop&firewalld.service&&&&&&&&&&
sudo&systemctl&disable&firewalld.service
最近更新的命令
在Linux命令大全(man.linuxde.net)可以查询您所需要的Linux命令教程和相关实例。如果您觉得本站内容对您有所帮助,请推荐给更多需要帮助的人。安全检查中...
请打开浏览器的javascript,然后刷新浏览器
< 浏览器安全检查中...
还剩 5 秒&你的位置: >
> Linux将应用添加到service,并设置自动启动
一般来说,服务器是极少重启的。如果必须重启,很多程序,如:shadowsocks server,还要重新远程启动,很麻烦的。所以将程序添加到开机运行中是件很方便的事情。
添加应用到service
创建脚本 /etc/init.d/shadowsocks 文件(其实也是 /etc/rc.d/init.d/shadowsocks 文件):
$ sudo vim /etc/init.d/shadowsocks
添加以下内容:
# shadowsocks start/restart/stop shadowsocks
# chkconfig:
# description: start shadowsocks/ssserver at boot time
ssserver -c /etc/shadowsocks.json -d start
ssserver -c /etc/shadowsocks.json -d stop
restart(){
ssserver -c /etc/shadowsocks.json -d restart
case "$1" in
echo "Usage: $0 {start|restart|stop}"
懂bash,或者其他程序语言语法的,应该都看得懂是什么意思吧!其中:
前面的几行,看起来像注释,特别chkconfig那一行,不可删除,否则无法设置开机启动,会提示错误:service shadowsocks does not support chkconfig
chkconfig:
中,2345代表在设置在那个level中是on的。如果一个都不想on,那就写一个横线"-",比如:chkconfig: - 85 15。后面两个数字代表S和K的默认排序号
然后增加这个文件的可执行权限:
$ sudo chmod +x /etc/init.d/shadowsocks
这样就可以在 shell 中直接运行下面的命令开启程序了(重启和停止同理):
$ sudo service shadowsocks start
这里以root权限运行的,如果不想以root权限运行可以用 sudo -u {user} {command}。
如果不给脚本文件加上其他用户的可执行权限,不带参数运行 service shadowsocks 会提示 unrecognized service。
设置开机启动
在上面脚本没有问题(也就是保留了前面10行,并且语法正确)的情况下,通过下面的命令,就可以设置程序自动启动了:
$ sudo chkconfig shadowsocks on
这样程序就会自动启动了。
Ubuntu添加开机启动服务的官方文档:。
关于启动的内容还有更多:。linux上像服务一样启动python程序,开机自动启动,能够start,stop,restart,status等?-linux系统里出现 Usage:services.s...
客服专线电话
你现在的位置: 》
linux上像服务一样启动python程序,开机自动启动,能够start,stop,restart,status等?
来源:食品厂整理&&&更新日期:
linux上像服务一样启动python程序,开机自动启动,能够start,stop,restart,status等?80分
相关说明:
ubuntu linux
的python脚本要做到可以被service来管理、将该脚本放到&#47;etc&#47;rc,例如:#!&#47;bin&#47,无需将python脚本包到shell脚本里。如.&#47;somescript.py start 这种命令格式来启动程序4,实现以下六个步骤即可:1、系统有相应的python解释器,并在脚本头部声明: ;usr&#47;init.d&#47;路径下5;python2.d&#47、给予该脚本可执行权限,如:chmod +x somescript.py3、脚本接受第一个命令参数,需要能接受至少包含start的参数,至于stop、restart以及status等并不是必须的,你可以自己来扩展
自行写成服务脚本即可。ubuntu可以用upstart,centos6只能用init了,centos7上可以用systemd
linux系统里出现 Usage:services.sh{start|stop|starus|res...:
linux系统里出现 Usage:services.sh{start|stop|starus|res...
ubuntu在启动时如何自动启动一个python脚本,比如将启动时间写入到一个指定文件里:
可以在一系统启动的几个文件里加载这个脚本。或者写成一个service加到系统......
怎么让我的python程序 在linux上以服务的形式运行:
编辑用户的Crontab文件 crontabl -e 名称 : crontab 使用权限 : 所有使...
linux 怎么启动 python 程序运行:
终端命令行执行python脚本文件:$ python 文件名 python脚本文件名是以 .py 结...
如何在linux下运行python程序:
先将终端所在路径切换到python脚本文件的目录下然后给脚本文件运行权限,一般755就OK,如果完全...
如何在linux下运行python程序:
现在一般的linux都预装了python2.x 直接在命令行里运行就行了 python xx.py就...
你可能感兴趣的相关文章

我要回帖

更多关于 python调用linux命令 的文章

 

随机推荐