Linux下,设置各种服务的开机自启动
来源:互联网 发布:云计算的特点以为中心 编辑:程序博客网 时间:2024/04/29 05:29
首先,在Windows里,编写bash脚本,测试其中各命令都是可用的。我写的脚本(yl_services)如下:
#!/bin/bash#Start all kinds of services#mysql#/usr/local/mysql/bin/#start mysql#postgres#su - postgres -c "/usr/local/pgsql/bin/postmaster -D '/data/db/postgres' &" >>"/data/db/postgres/serverlog" 2>&1su - postgres -c "/usr/local/pgsql/bin/pg_ctl start"#nginxsu - root -c "usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf"#tomcat:desktopsu - root -c "/home/desktop/apache-tomcat-7.0.42/bin/startup.sh"#desktop-serversu - root -c "/home/desktop/desktop-server/bin/boot.sh start"
其中,mysql会自启动,postgres和nginx,tomcat,desktop-server等服务,用此脚本启动。
然后,将该脚本保存成Unix格式(Unix的换行符是0x0A,而Windows的回车换行符是0x0D0x0A);
然后,将它复制到Linux系统(/home),修改为可执行(chmod 777 /home/yl_services);
然后,用如下命令,将该脚本链接到启动目录(/etc/init.d)中,并链接到对应的运行等级目录中;
[root@localhost ~]# ln -s /home/yl_services /etc/init.d/
[root@localhost ~]# ln -s /etc/init.d/yl_services /etc/rc2.d/S99ylServices
[root@localhost ~]# ln -s /etc/init.d/yl_services /etc/rc3.d/S99ylServices
注:rc2.d和rc3.d,分别对应运行等级的2和3;其下的链接以S开头,启动时会被执行到!
0 0
- Linux下,设置各种服务的开机自启动
- Linux设置程序的开机自启动与Linux服务
- Linux 下服务自启动的设置
- Linux设置开机自启动服务
- linux设置服务开机自启动的三种方式
- Linux下设置MongoDB开机自启动
- Linux下设置MongoDB开机自启动
- Linux下设置开机自启动Tomcat
- Linux下设置Oracle开机自启动
- Linux下设置开机自启动Tomcat
- Linux下设置开机自启动Tomcat
- Linux下设置MongoDB开机自启动
- linux下redis设置开机自启动
- Linux下设置开机自启动Tomcat
- Linux下设置svn开机自启动
- Linux下设置开机自启动Tomcat
- Linux下设置开机自启动Tomcat
- linux下redis设置开机自启动
- GridView 导出到 Excel 文件报错解决办法
- ArcGIS 10.2.2 for Server新特性介绍
- Unity3D 画线插件 Vectrosity_Simple2DLine
- VC 加载图片的方法
- 关于期初期末值累加的SQL语句
- Linux下,设置各种服务的开机自启动
- 嵌入式C语言面试题
- 怎么在html页面中调用css文件
- android谈Content Provider的Uri
- java套打
- java 设计模式
- linux下查看cpu物理个数和逻辑个数
- Keil C中如何直接打印char类型变量
- 《Intent的一些用法(不断更新)》