Linux多线程实例 定时重启httpd和mysqld
#include <stdio.h>
#include <pthread.h> void *start_routine(void *arg)
{
while(1)
{
system("service httpd restart");
system("service mysqld restart");
sleep(60*60*6);
} int retvalue = 0;
pthread_exit((void*)&retvalue);
} int main()
{
pthread_t pt;
int ret;
ret = pthread_create(&pt,NULL,(void*)start_routine,0);
if(ret != 0)
{
printf("create thread error");
return 0;
}
int *ret_join = NULL;
pthread_join(pt,(void*)&ret_join);
printf("retvalue: %d\n",*ret_join);
return 0;
}
gcc test.c -o test -lpthread
Linux多线程实例 定时重启httpd和mysqld的更多相关文章
- Linux多线程实例练习 - pthread_cancel()
Linux多线程实例练习 - pthread_cancel 1.代码 xx_pthread_cancel.c #include <pthread.h> #include <stdio ...
- Linux多线程实例练习 - pthread_exit() 与 pthread_join()
Linux多线程实例练习 - pthread_exit 与 pthread_join pthread_exit():终止当前线程 void pthread_exit(void* retval); pt ...
- Linux多线程实例练习 - pthread_create()
Linux多线程实例练习 pthread_create():创建一个线程 int pthread_create(pthread_t *tidp, const pthread_attr_t *attr, ...
- Linux多线程实例解析
Linux系统下的多线程遵循POSIX线程接口,称为 pthread.编写Linux下的多线程程序,需要使用头文件pthread.h,连接时需要使用库libpthread.a.顺便说一下,Linux ...
- Linux CentOS设置定时重启:crontab
上一篇介绍了 开机自启动chkconfig命令 https://www.cnblogs.com/prefectjava/p/9399470.html 本篇介绍 crontab 设置定时任务,并且把 ...
- linux定时重启tomcat服务的脚本学习
要求:在linux中定时重启一个tomcat服务 一:shell脚本即Shell Script [1],Shell脚本与Windows/Dos下的批处理相似,也就是用各类命令预先放入到一个文件中,方便 ...
- 【树莓派】crontab设置Linux设备定时重启
简介:设置Linux设备定时重启或者关机 问题:有台设备每天总需要使用的人手动重启一下才可以正常工作,但是检查了日志,看起来服务一切都正常.时间和正确时间相差4mins. 解决办法: 1.增加定时任务 ...
- linux定时重启节约内存
linux服务器上运行的一些程序,比较消耗内存,需要定时重启,进行内存定期释放 0 2 * * * sudo /sbin/reboot && echo $(date) '重启成功' ...
- Linux 定时重启 Tomcat、重启Keepalived
1.在 tomcat 目录新建一个.sh 文件: vi restartTomcat.sh 2.输入内容: #!/bin/bash# author: Linnuo # date: -- # Filena ...
随机推荐
- (17)zabbix自定义用户key与参数User parameters
为什么要自定义KEY 有时候我们想让被监控端执行一个zabbix没有预定义的检测,zabbix的用户自定义参数功能提供了这个方法. 我们可以在客户端配置文件zabbix_angentd.conf里面配 ...
- python爬虫入门七:pymysql库
我们使用python爬取得到的数据,有时候会数据量特别大,需要存入数据库. 需要注意的是,MySQL是一种关系型数据库管理系统,利用MySQL可以对数据库进行操作,而MySQL并不是一个数据库. 而p ...
- ERROR! The server quit without updating PID file (/usr/local/var/mysql/bogon.pid).
本文转载自http://www.jb51.net/article/48625.htm 今天网站web页面提交内容到数据库,发现出错了,一直提交不了,数找了下原因,发现数据写不进去!第一反应,重启mys ...
- Codeforces C. Sonya and Problem Wihtout a Legend(DP)
Description Sonya was unable to think of a story for this problem, so here comes the formal descript ...
- AtCoder Beginner Contest 098 D - Xor Sum 2
D - Xor Sum 2 Time limit : 2sec / Memory limit : 1024MB Score : 500 points Problem Statement There i ...
- spring mvc3 配置<mvc:resources/> @Controller失效
因为配置了:<mvc:resources location=" " mapping="" /> ,@Controller失效访问404 这里还 ...
- PAT Basic 1038
1038 统计同成绩学生 本题要求读入N名学生的成绩,将获得某一给定分数的学生人数输出. 输入格式: 输入在第1行给出不超过10^5^的正整数N,即学生总人数.随后1行给出N名学生的百分制整数成绩,中 ...
- python基础-面向对象(类)
类 类的定义 >>> class P: ... pass ... >>> P <class __main__.P at 0x0000000001F4B ...
- 10大vim插件
Taglist taglist是一个用于显示定位程序中各种符号的插件,例如宏定义.变量名.结构名.函数名这些东西 我们将其称之为符号(symbols),而在taglist中将其称之为tag.显然,要想 ...
- 用KMP征服循环节问题
以前我还是写过KMP的文章的 现在我们可以求一下循环节啊 Slot Machines Gym - 101667I #include<bits/stdc++.h> using namespa ...