Fedora 16设置开机自启动程序与Ubuntu的区别
Ubuntu设置开机自启动脚本的方法是:修改/etc/init.d/rc.local这个文件,添加需要启动的程序即可,相关函数如下:
void SetSysAutoBoot()
{
char path[] = {};
int ret = ; ret = readlink("/proc/self/exe",path,sizeof(path)); if((ret > )&& (ret < sizeof(path)))
{
printf("system path : %s\n",path);
} char* fileName = "/etc/init.d/rc.local";
int fileLen = GetFileSize(fileName); FILE * fp = fopen(fileName,"r+");
char* buf; buf = (char*)malloc(fileLen*);
char* tempBuf = buf; if(fp == NULL)
{
return;
} int flag = ; while(!feof(fp))
{
tempBuf = fgets(buf,fileLen,fp); if(tempBuf != buf)
{
break;
} //exist
if(strstr(tempBuf,path) != )
{
//
flag = ;
} } fclose(fp); //not exist
if( == flag)
{
char buf[];
sprintf(buf,"echo \"%s &\" >> /etc/init.d/rc.local\n",path);
printf(buf);
system(buf);
} free(buf);
}
但是FC16系统并不系统自带/etc/init.d/rc.local这个文件,于是我们就要自作做一些配置了。
1. 首先写一个测试脚本,
touch /etc/rc.d/rc.local
这个文件的内容是:
#!/bin/sh
date >> /IpMonitor/test.txt
/IpMonitor/IpMonitor-Server &
设置可执行权限:
chmod 777 /etc/rc.d/rc.local
设置软链接:
ln -s /etc/rc.d/rc.local /etc/rc.local
2. 开启rc-local.service
systemctl start rc-local.service
3. reboot即可看到效果了。
top - :: up min, users, load average: 1.37, 0.57, 0.21
Tasks: total, running, sleeping, stopped, zombie
Cpu(s): 0.0%us, 0.2%sy, 0.0%ni, 99.5%id, 0.1%wa, 0.2%hi, 0.1%si, 0.0%st
Mem: 8152824k total, 442280k used, 7710544k free, 488k buffers
Swap: 4095996k total, 0k used, 4095996k free, 137048k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
root 441m S 0.7 0.0 :00.33 IpMonitor-Serve
root S 0.0 0.1 :01.32 systemd
root S 0.0 0.0 :00.00 kthreadd
root S 0.0 0.0 :00.01 ksoftirqd/
root S 0.0 0.0 :00.00 kworker/:
root S 0.0 0.0 :00.00 kworker/u:
root RT S 0.0 0.0 :00.00 migration/
root RT S 0.0 0.0 :00.00 watchdog/
root RT S 0.0 0.0 :00.00 migration/
root S 0.0 0.0 :00.02 kworker/:
root S 0.0 0.0 :00.00 ksoftirqd/
root S 0.0 0.0 :00.02 kworker/:
root RT S 0.0 0.0 :00.00 watchdog/
root RT S 0.0 0.0 :00.00 migration/
root S 0.0 0.0 :00.00 kworker/:
root S 0.0 0.0 :00.00 ksoftirqd/
root RT S 0.0 0.0 :00.00 watchdog/
root RT S 0.0 0.0 :00.00 migration/
root S 0.0 0.0 :00.00 kworker/:
root S 0.0 0.0 :00.00 ksoftirqd/
root RT S 0.0 0.0 :00.00 watchdog/
root RT S 0.0 0.0 :00.00 migration/
root S 0.0 0.0 :00.00 kworker/:
root S 0.0 0.0 :00.00 ksoftirqd/
root RT S 0.0 0.0 :00.00 watchdog/
root RT S 0.0 0.0 :00.00 migration/
root S 0.0 0.0 :00.00 kworker/:
root S 0.0 0.0 :00.00 ksoftirqd/
root RT S 0.0 0.0 :00.00 watchdog/
root RT S 0.0 0.0 :00.00 migration/
root S 0.0 0.0 :00.00 kworker/:
root S 0.0 0.0 :00.00 ksoftirqd/
root RT S 0.0 0.0 :00.00 watchdog/
root RT S 0.0 0.0 :00.00 migration/
root S 0.0 0.0 :00.00 kworker/:
root S 0.0 0.0 :00.00 ksoftirqd/
root RT S 0.0 0.0 :00.00 watchdog/
root - S 0.0 0.0 :00.00 cpuset
root - S 0.0 0.0 :00.00 khelper
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# cat /IpMonitor/test.txt
2013年 07月 05日 星期五 :: CST
2013年 07月 05日 星期五 :: CST
2013年 07月 05日 星期五 :: CST
2013年 07月 05日 星期五 :: CST
2013年 07月 05日 星期五 :: CST
2013年 07月 05日 星期五 :: CST
Fedora 16设置开机自启动程序与Ubuntu的区别的更多相关文章
- linux_设置开机自启动程序脚本
设置开机自启动
- win10设置开机自启动程序
问题情境:前两天刚刚给自己的win10系统美化了一下,但发现一个问题,每次开机都需要双击启动一个程序,才能达到一个我想要的效果,所以就在思考能不能将这个程序设为开机自启动项呢? 1.首先,找到启动文件 ...
- Ubuntu14.04设置开机自启动程序
启动应用程序可以帮助我们选择开机启动项.但是在Ubuntu14.04通过Dash输入startup 找不到启动应用程序了,可以通过在控制台输入以下内容: gnome-session-propertie ...
- Windows 7硬盘安装CentOS 6.4 双系统 (WIN7硬盘安装Linux(Fedora 16,CentOS 6.2,Ubuntu 12.04))
WIN7下硬盘安装Linux(Fedora 16,CentOS 6.2.Ubuntu 12.04) 近期在看<鸟哥私房菜:基础学习篇>.认为非常不错,想要用U盘装个windows 7 和 ...
- Windows 7硬盘安装CentOS 6.4 双系统 (WIN7下硬盘安装Linux(Fedora 16,CentOS 6.2,Ubuntu 12.04))
WIN7下硬盘安装Linux(Fedora 16,CentOS 6.2,Ubuntu 12.04) 最近在看<鸟哥私房菜:基础学习篇>,觉得很不错,想要用U盘装个windows 7 和 ...
- Ubuntu14.04设置开机自启动脚本
方法一.编辑rc.loacl脚本 Ubuntu开机之后会执行/etc/rc.local文件中的脚本,所以我们可以直接在/etc/rc.local中添加启动脚本.在 exit 0 前面添加好脚本代码, ...
- Android开机自启动程序
背景知识:当Android启动时,会发出一个系统广播,内容为ACTION_BOOT_COMPLETED,它的字符串常量表示为 android.intent.action.BOOT_COMPLETED. ...
- 设置开机自启动VirtualBox虚拟机系统
如果常用VirtualBox虚拟机系统的话,设置个随开机启动也是很方便的.不需要打开VirtualBox窗口,直接就是系统启动了. 又继续上网搜索学习了.(设置开机自启动VirtualBox虚拟机系统 ...
- CentOS7设置开机自启动方式
方式一: # 在/etc/rc.d/rc.local文件中追加启动命令,该文件追加后,会随着机器自动后,自动运行文件中的命令 # vim /etc/rc.d/rc.local # 权限问题:在cent ...
随机推荐
- C#分页类
using System.Linq; using System.Collections.Generic; namespace CommonLibrary { public class PagedLis ...
- Hadoop实战课程
Hadoop生态系统配置Hadoop运行环境Hadoop系统架构HDFS分布式文件系统MapReduce分布式计算(MapReduce项目实战)使用脚本语言Pig(Pig项目实战)数据仓库工具Hive ...
- Http进行网络通信
http使用get的方式进行网络通信: package com.testGet; import java.io.BufferedReader; import java.io.IOException; ...
- LA 3516 Exploring Pyramids (记忆化搜索)
题意 给定一个DFS序列,问能有多少树与之对应. 思路 设输入序列为S,dp(i, j)为子序列Si, Si+1, --, Sj对应的树的个数,则边界条件为d(i, i) = 1,且Si != Sj时 ...
- python练习程序(c100经典例11)
题目: 古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少? a=1;b=1 print a,b, for i ...
- Linux编程(获取系统时间)
#include <stdio.h> #include <time.h> int main() { time_t now; struct tm *w; time(&no ...
- 如何调试Android Framework?
Linus有一句名言广为人知:Read the fucking source code. 但其实,要深入理解某个软件.框架或者系统的工作原理,仅仅「看」代码是远远不够的.就拿Android Frame ...
- Android 注解的一些应用以及原理
在这边文章之前你首先需要对java 的注解部分有一个基本的了解(不需要太过的深入). 简单来说,注解这个东西就是用于辅助我们开发java代码的,注解本身无法干扰java源代码的执行. 在android ...
- python-socket.error[10054]:对象的复制
1.socket.error[10054],对方强制关闭了连接 在用socket.recvfrom时,若事先没有bind时, 先使用socket.sendto,socket.recvfrom 有时会出 ...
- PHPMailer邮件类使用错误分析
PHPMailer配置清单如下: require_once ‘class.phpmailer.php‘; $receiver = ”; $mail = new PHPMailer ( ); $mai ...