c语言 线程a每隔10秒执行一次,线程b每隔100秒执行一次,每隔100ms运行一次php脚本(run php script after every 100ms)...

博客讨论了如何在Linux环境下每隔100毫秒运行PHP脚本,用于实时检查数据库变化并同步到其他数据库。除了使用触发器外,还探讨了创建守护进程或使用定时任务替代Cron和Triggers的可能性。
摘要由CSDN通过智能技术生成

每隔100ms运行一次php脚本(run php script after every 100ms)

是否可以在每100毫秒后运行一个PHP脚本? 此脚本将检查数据库是否有更改,然后更改将反映到其他一些数据库中。 我已经使用触发器做了。 但是我想知道在没有使用Cron和Triggers的情况下是否还有其他方法可以做到这一点。 我将为此目的使用Linux。 谢谢

Is it possible to run a php script after every 100ms ? This script will check a database for changes and then the changes will be reflected into some other database. I am already doing it using Triggers. But I want to know if there is any other way to do it without using Cron and Triggers. I will be using Linux for this purpose. Thanks

原文:https://stackoverflow.com/questions/5762442

更新时间:2020-01-03 21:47

最满意答案

Running something every 100ms almost means that it runs all the time , might as well create a daemon that continuously loops and executes

or use triggers. Essentially on every database change it will copy to another table/db.

2011-04-23

相关问答

问题是您的客户端正在

在Linux环境下使用C语言编写一个简单的线程创建函数,通常会使用POSIX线程库(pthreads)。这里是一个简单的示例: ```c #include <pthread.h> #include <stdio.h> // 线程函数的原型 void* thread_function(void* arg); // 主要函数,创建并启动新线程 int create_thread(const char* thread_name, void (*thread_func)(void*)) { pthread_t thread_id; // 用于存储线程ID int result; if ((result = pthread_create(&thread_id, NULL, thread_func, (void*)thread_name)) != 0) { printf("Error creating thread: %d\n", result); return -1; } printf("Thread '%s' created successfully with ID %lu\n", thread_name, (unsigned long)thread_id); return 0; } // 线程函数的具体实现 void* thread_function(void* thread_data) { char* name = (char*)thread_data; printf("Thread '%s' is running...\n", name); // 这里可以添加线程的实际工作 return NULL; } int main() { const char* thread_name = "My Thread"; create_thread(thread_name, thread_function); return 0; } ``` 关于CMake脚本,你需要配置链接到`libpthread`库,并指定源文件。这是一个基本的CMakeLists.txt示例: ```cmake # CMakeLists.txt cmake_minimum_required(VERSION 3.10) project(MyProject) # 添加C/C++支持 add_library(MyProject src/main.c src/thread_function.c) # 链接到POSIX线程库 target_link_libraries(MyProject pthread) ``` 在这个CMake文件中,`src/main.c`和`src/thread_function.c`分别代表包含上述代码片段的源文件。当你运行`cmake .`生成构建系统,然后`make`来编译和链接程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值