English 中文(简体)
测试Crontab,Debian Hugo
原标题:Testing Crontab on Debian Ubuntu

I will preface this by saying I am very new to command line programming with Debian Ubuntu...

I have been trying to set up a crontab list on a Debian Ubuntu server but have not been able to get it to work. Here is a sample:

MAILTO=myemail@gmail.com
* * * * * wall test
* * * * * /usr/bin/python2.6 /home/user/test.py > /home/user/clean_tmp_dir.log

以上显示的是,“crontab-l”这一类型,但没有产生结果。 “测试.py”本应产生一只 file子,但并未创建。

我没有收到任何产出/电子邮件。 我试图找到一个标识,但“var/log/ron”并不存在,也不存在“etc/syslog.conf”。 我试图ed“etc/rsyslog.conf”,但去“E212: Can t open file for written”. 然而,我gged。 我是否需要某种特殊的行政特权? 我是否需要具体说明用户或“机器”或什么?

Does anyone know what I m doing wrong, how I can create/view a log, or how I can perform any other straightforward tests? Thanks!

最佳回答

奥基,请再次开始。

创建文档,如<条码>cron.txt,其中准确列出以下内容(1行):

* * * * * touch $HOME/CRON_IS_RUNNING

(Do not create CRON_IS_RUNNING manually.) Run

crontab cron.txt

后者应不产生任何产出,然后

crontab -l

印刷

* * * * * touch $HOME/CRON_IS_RUNNING

Wait a minute or so, perhaps 2 minutes, then

ls -l $HOME/CRON_IS_RUNNING

印刷 something like

-rw-r--r-- 1 yourname yourgroup 0 2011-08-23 20:11 CRON_IS_RUNNING

如果所有这些工作都可行,它将确认你可以从事 cr工作。

如果成功的话,问题可能在于你的<编码>测试.py指挥。 它是在你从指挥线接手的时候吗? 如果它从指挥线运作,而不是从<代码>cron运作,<代码>test.py可能在一定程度上依赖环境变量(按时间顺序排列的环境变量少于互动指挥)。

问题回答

The syntax in your wall command is wrong. To output a direct message you need to use the syntax: echo test | wall . wall test will look for a file named test.

Any cron messages will be in /var/log/syslog

页: 1 所有人

用户名称:crontab

我对我的“Debian Squeeze”系统进行了测试,你作为根基用户,稍作修改。

我建立了档案测试。 py with:

#!/usr/bin/python
print "hello"

建立了隔离墙档案试验:

this is a test

接着又开了 cr,在我的 cr子中增加了:

MAILTO=myemail@gmail.com
* * * * * wall /usr/local/src/test
* * * * * /usr/bin/python2.6 /usr/local/src/test.py > /usr/local/src/test.log

当它向屏幕投产时:

Broadcast Message from root@X-Wing                                             
        (somewhere) at 21:09 ...                                               

This is a test   

测试内容包括:

hello

添加到/瓦尔/log/log中:

Aug 23 21:08:49 x-wing crontab[9850]: (root) REPLACE (root)
Aug 23 21:08:49 x-wing crontab[9850]: (root) END EDIT (root)
Aug 23 21:09:01 x-wing /usr/sbin/cron[1615]: (root) RELOAD (crontabs/root)
Aug 23 21:09:02 x-wing /USR/SBIN/CRON[9860]: (root) CMD (/usr/bin/python2.6 /usr/local/src/test.py > /usr/local/src/test.log)
Aug 23 21:09:02 x-wing /USR/SBIN/CRON[9862]: (root) CMD (wall /usr/local/src/test)




相关问题
Add a changing icon to Ubuntu Panel

What would be the most simple way of adding and changing an icon in the Ubuntu (Gnome) Panel? I m looking for something as simple as shell scripting, but I m not restricted to that. Will write a ...

Configuring kernel

After create a new system call, how to update the kernel? I tried these lines, make-kpkg clean fakeroot make-kpkg -initrd -append-to-version=-custom kernel_image kernel_headers But Ubuntu asked me ...

save Exceptions to file in python

I want to save all following Exceptions in a file. The reason why I need this is because the IDLE for python 3.1.1 in Ubuntu raises an Exception at calltipps, but close to fast, that it isn t readble. ...

How can i monitor system statistics in kubuntu using Java?

i am doing a project related to configuration and memory analyzer for kubuntu. i want to display the system statistics information like CPU usage, RAM usage and proceses etc. graphically using an ...

How to pass "--external-locking" for mysqld in Ubuntu

I would like to start my mysql server with the --external-locking option. As mysqld is run by the /etc/init.d/mysql script ubuntu (karmic), I guess that s where I should set this "--external-locking" ...

"g++" and "c++" compiler

I just found on my Ubuntu, there are two different C++ compilers: /usr/bin/g++ and /usr/bin/c++. I am not familiar with the latter, but man c++ just jumps to the manpage of gcc. I wonder what is their ...

热门标签