CRONJOB - Crontab命令无法正常运行ubuntu

时间:2017-12-07 10:27:24

标签: shell cron apache-zookeeper

大家好,

目前在我的项目中,我们在Aws实例中使用了Spark zookeeper Kafka Storm Eagle。突然间,所有的服务都会崩溃。所以我们确定了这个问题,发现zookeeper占用了更多的空间。

sudo du -x / | sort -n | tail -40
5070384 /tmp/zookeeper/version-2
5070392 /tmp/zookeeper
5095832 /tmp

root@ip:/tmp/zookeeper/version-2# ls -ltr
total 5071368
-rw-r--r-- 1 root root     137034 Dec  5 13:23 snapshot.38c1b0
-rw-r--r-- 1 root root 1946157072 Dec  6 05:41 log.38c1b2
-rw-r--r-- 1 root root     137621 Dec  6 05:41 snapshot.3a206a
-rw-r--r-- 1 root root 2080374800 Dec  6 23:03 log.3a206c
-rw-r--r-- 1 root root     136887 Dec  6 23:03 snapshot.3b9608
-rw-r--r-- 1 root root 1342177296 Dec  7 10:02 log.3b960a

为了清除以上位置,我使用了以下命令     zkCleanup.sh / tmp / zookeeper -n 3。     它运作得很好。

所以我们决定自动化这个过程。创建了一个具有root权限的shell脚本文件zkClean.sh。

root@ip:/home# ls -ltr
-rw-r--r-- 1 root   root       22928 Nov 22 06:50 zookeeper.out
**-rwxr-xr-x 1 root   root          45 Nov 29 07:21 zkClean.sh**

root@ip:/usr/pricchaa/zookeeper-3.4.9/bin# ls -ltr
total 36
-rwxr-xr-x 1 tomcat tomcat 6773 Aug 23  2016 zkServer.sh
-rwxr-xr-x 1 tomcat tomcat 1065 Aug 23  2016 zkServer.cmd
-rwxr-xr-x 1 tomcat tomcat 2696 Aug 23  2016 zkEnv.sh
-rwxr-xr-x 1 tomcat tomcat 1579 Aug 23  2016 zkEnv.cmd
-rwxr-xr-x 1 tomcat tomcat 1534 Aug 23  2016 zkCli.sh
-rwxr-xr-x 1 tomcat tomcat 1032 Aug 23  2016 zkCli.cmd
-rwxr-xr-x 1 root   root   1937 Aug 23  2016 zkCleanup.sh**
-rwxr-xr-x 1 tomcat tomcat  232 Aug 23  2016 README.txt

Fyi - 当我使用./zkClean.sh执行shell脚本时,它可以找到,但它在cron作业中不起作用。

我也创建了一个sudo crontab来安排每分钟。

root user => crontab -e

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
0 */1 * * * /home/ubuntu/downloadS3File.sh
#0 12 * * mon /home/ubuntu/zkClean.sh
    * * * * * /home/ubuntu/zkClean.sh

但是我的cronjob并没有因为一直在运行。你能帮助我的人能帮助我吗?

0 个答案:

没有答案