ubuntu 10.10中的Php Cron工作不执行lampp - 需要帮助(Php Cron job in ubuntu 10.10 does not execute for lampp - Help needed)
我需要一些日常cron工作的帮助,我想在ubuntu 10.10下安排。 我通过
crontab -e
添加了这个工作,当我做crontab -l
,它看起来没问题。 路径和命名都很好:58 23 * * * /usr/bin/php -f /home/eem/cars1/cron/cronjob1.php
但是,cron不会执行。 我试图从gnome调度程序手动运行它。 没有成功。 我厌倦了使用此命令从控制台手动运行它,再次没有成功:
/usr/bin/php -f /home/eem/cars1/cron/cronjob1.php
我的var / log / syslog显示该文件已执行但Xampp上的网站没有任何变化:
May 14 06:27:57 eem-VirtualBox /usr/bin/crontab[31959]: (eem) LIST (eem)
此命令:
*/5 * * * * echo hello
crontab -e
*/5 * * * * echo hello
执行并显示在syslog中:May 14 05:40:01 eem-VirtualBox CRON[31085]: (eem) CMD (echo hello) May 14 05:40:01 eem-VirtualBox CRON[31084]: (CRON) info (No MTA installed, discarding output)
下面是一些诊断:
Command1 :
ps -C cron
终端 :
PID TTY TIME CMD 881 ? 00:00:02 cron
var / log / syslog :
May 14 05:17:01 eem-VirtualBox CRON[31033]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Command2 ::
cat /etc/crontab
终奌站:
SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) #
Command3:
ls /usr/sbin/anacron
终端:
/usr/sbin/anacron
Command4:
grep CRON /var/log/syslog
终端:这个以及更多:
5月14日05:09:01 eem-VirtualBox CRON [30048] :( root)CMD([-x / usr / lib / php5 / maxlifetime] && [-d / var / lib / php5] && find / var / lib / php5 / -depth -mindepth 1 -maxdepth 1-type f -cmin + $(/ usr / lib / php5 / maxlifetime)! - execdir fuser -s {} 2> / dev / null \; -delete)5月14日05: 17:01 eem-VirtualBox CRON [31033] :( root)CMD(cd / && run-parts --report /etc/cron.hourly)
为长篇大论道歉,但经过几天的挣扎,我迫不及待地想找到问题。 希望在此之后对其他人有所帮助。
I need some help with a daily cron job I am trying to schedule under ubuntu 10.10. I have added the job via
crontab -e
and when I docrontab -l
, it looks ok. Path and naming are fine:58 23 * * * /usr/bin/php -f /home/eem/cars1/cron/cronjob1.php
However, the cron does not execute. I have tried to run it manually from gnome scheduler. No success. I tired to run it manually from the console with this command, again without success:
/usr/bin/php -f /home/eem/cars1/cron/cronjob1.php
My var/log/syslog show that the file is executed but nothing changes in the website on Xampp:
May 14 06:27:57 eem-VirtualBox /usr/bin/crontab[31959]: (eem) LIST (eem)
This command:
*/5 * * * * echo hello
incrontab -e
executes and shows in syslog:May 14 05:40:01 eem-VirtualBox CRON[31085]: (eem) CMD (echo hello) May 14 05:40:01 eem-VirtualBox CRON[31084]: (CRON) info (No MTA installed, discarding output)
Below some diagnostics:
Command1:
ps -C cron
Terminal:
PID TTY TIME CMD 881 ? 00:00:02 cron
var/log/syslog:
May 14 05:17:01 eem-VirtualBox CRON[31033]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Command2::
cat /etc/crontab
Terminal:
SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) #
Command3:
ls /usr/sbin/anacron
Terminal:
/usr/sbin/anacron
Command4:
grep CRON /var/log/syslog
Terminal:: This and much more:
May 14 05:09:01 eem-VirtualBox CRON[30048]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete) May 14 05:17:01 eem-VirtualBox CRON[31033]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Apologies for the long post but after struggling for several days with this I am desperate to find the problem. Hopefully, it will be helpful to other people after that.
原文:https://stackoverflow.com/questions/22255623
最满意答案
查看
pthread_cancel
的手册页:当请求的取消被执行时,线程会发生以下步骤(按此顺序):
1. Cancellation clean-up handlers are popped (in the reverse of the order in which they were pushed) and called. (See pthread_cleanup_push(3).) 2. Thread-specific data destructors are called, in an unspecified order. (See pthread_key_create(3).) 3. The thread is terminated. (See pthread_exit(3).)
因此,如果您使用上述函数正确注册了清理处理程序,则可以使用main中的
pthread_cancel
。(尽管完全阅读了这个手册页,它有很多重要的信息。)
编辑 :(来自评论)如果您打算使用
PTHREAD_CANCEL_DEFERRED
并且需要在代码中的某处插入取消点,请使用pthread_testcancel
。 此功能检查是否请求取消。 如果是这种情况,则取消服务(即该呼叫永远不会返回)。 否则它没有效果。Look at the man page for
pthread_cancel
:When a cancellation requested is acted on, the following steps occur for thread (in this order):
1. Cancellation clean-up handlers are popped (in the reverse of the order in which they were pushed) and called. (See pthread_cleanup_push(3).) 2. Thread-specific data destructors are called, in an unspecified order. (See pthread_key_create(3).) 3. The thread is terminated. (See pthread_exit(3).)
So you can use
pthread_cancel
from your main, provided you have registered you cleanup handlers correctly using the above functions.(Do read that man page completely though, it has a lot of important information.)
Edit: (from comments) If you plan on using
PTHREAD_CANCEL_DEFERRED
and need to insert a cancellation point somewhere in your code, then usepthread_testcancel
. This function checks if a cancellation was requested. If that is the case, the cancellation is serviced (i.e. that call never returns). Otherwise it has no effect.
相关问答
更多-
boost:线程没有执行接收信号后发布的处理程序(boost: thread not executing an handler posted after the reception of a signal)[2023-06-08]
我可以看到线程运行,信号被截获 你确定吗? 我认为信号不是发送的事件。 但是没有执行发布的处理程序。 我究竟做错了什么? 您的构造函数创建一个新线程,然后等待它完成,因此构造函数不会返回,直到新线程退出。 这意味着在接收器线程退出之前, main这一行不会执行: Package1Signals::getInstance()->signal1(); 也许您希望boost::thread成为您的类的成员,因此它与您的类具有相同的生命周期,而不是构造函数中的局部变量。 对于样式考虑,你不需要使用boost:: ... -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
管道上的阻塞read是异步信号安全的 ,并提供了一种方便的方法来唤醒“挂起”线程。 例如, static int the_pipe[2] = {-1, -1}; // file descriptors allocated in main via pipe() static void siginfo_handler(int s, siginfo_t *si, void *ctx) { char c; // do something with (ucontext_t *)ctx // now ...
-
信号处理 - 异步功能和多线程应用程序,信号堆栈(Signal handling - Async functions and multi threaded applications, Signal stack)[2024-01-29]
当进程收到信号时,它将在进程的上下文中处理。 您应该只在信号处理程序中使用异步安全函数或重入函数。 例如,您不能在信号处理程序中调用malloc()或printf()。 原因是: *)假设您收到信号时您的进程正在malloc中执行。 因此全局堆数据结构处于不一致状态。 现在,如果从信号处理程序内部获取堆锁并进行更改,则会进一步使堆不一致。 *)另一种可能性是,如果你的进程在接收到信号时已经获取了堆锁,然后你从信号处理程序调用malloc(),它会看到锁被保持并且它无限地等待获取锁(无限因为在信号完全处理之前 ... -
子线程中的信号处理程序(signal handler in child thread)[2021-08-16]
有几个问题。 1)信号处理程序签名不正确。 它应该采用int而你没有参数定义它。 即 static void proxy_singnal_handler(){ 应该 static void proxy_singnal_handler(int sig){ 2)您不能从信号处理程序(在您的情况下为printf()中调用非异步信号安全的函数。 有关详细信息,请参阅信号(7) 。 您可以改为使用write(2)来打印该消息: printf("Hello\n"); 可: write(1, "Hello\n", ... -
正如此处所述: http : //www.gnu.org/software/libc/manual/html_node/Nonreentrancy.html#Nonreentrancy 如果一个函数使用并修改了你提供的对象,那么它可能是不可重入的; 如果两个调用使用同一个对象,则可能会造成干扰 在你的情况下,该对象是stdout 。 当信号到达(f)printf()的中间,并且如果在处理程序中使用(f)printf ,则两个数据在同一个流stdout上运行时可能会损坏。 重入是这种情况下的根本原因。 即使您 ...
-
从信号手册页 : 信号处理是一个每进程属性:在多线程应用程序中,特定信号的配置对于所有线程都是相同的。 所以,是的,当你设置一个信号处理程序时,它将处理发送给进程的信号; 信号不会单独发送到每个线程,它会被发送到任何一个未阻塞正在发送的特定消息的线程。 From the man page for signals: The signal disposition is a per-process attribute: in a multithreaded application, the disposition ...
-
当我在go中添加另一个阻塞线程时,为什么信号处理程序无效?(Why signal handler not work when I added another blocking thread in go?)[2024-02-16]
我做了一些调查,我发现问题的关键点不是线程,而是信号处理程序是否有足够的时间运行。 我做了一个简单的程序来重新生成Windows 7下的问题以及解决方案。 package main import ( "fmt" "io" "os" "os/signal" ) func main() { c := make(chan os.Signal, 1) //q := make(chan bool, 1) signal.Notify(c, os.Interru ... -
线程中的信号处理程序(signal handler in a thread)[2023-11-19]
查看pthread_cancel的手册页: 当请求的取消被执行时,线程会发生以下步骤(按此顺序): 1. Cancellation clean-up handlers are popped (in the reverse of the order in which they were pushed) and called. (See pthread_cleanup_push(3).) 2. Thread-specific data destructors are called, ... -
找不到信号处理程序(Signal handler not found)[2024-01-14]
这似乎是某种竞争条件,并且当有更多的事情发生时它会起作用。 use warnings; use strict; use feature 'say'; use threads; use threads::shared; my $thread_handler_on :shared = 0; sub test_handler { say "\tIn thread."; $SIG{'KILL'} = sub { $thread_handler_on = 1; s ...