使用Cron的Shell脚本无法执行shell命令

时间:2014-09-12 16:18:25

标签: cron openshift

我正在尝试用cron重启我的服务器。我找到了这个链接:

https://help.openshift.com/hc/en-us/articles/202187644-Shell-scripts-using-Cron-or-action-hooks-can-t-execute-shell-commands

但是不起作用。这是我的剧本:

#!/bin/bash
source /usr/bin/rhcsh
ctl_all restart

这就是输出:

/usr/bin/rhcsh: line 7: source: filename argument required
source: usage: source filename [arguments]
/usr/bin/rhcsh: line 32: build_path: command not found
/usr/bin/rhcsh: line 33: build_ld_library_path: No such file or directory
    *********************************************************************
    You are accessing a service that is for use only by authorized users.
    If you do not have authorization, discontinue use at once.
    Any use of the services is subject to the applicable terms of the
    agreement which can be found at:
    https://www.openshift.com/legal
    *********************************************************************
    Welcome to OpenShift shell
    This shell will assist you in managing OpenShift applications.
    !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
    Shell access is quite powerful and it is possible for you to
    accidentally damage your application.  Proceed with care!
    If worse comes to worst, destroy your application with "rhc app delete"
    and recreate it
    !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
    Type "help" for more info.
Command "quota" not found for app xxxxx, please check the node hosting this app
WARNING: This ssh terminal was started without a tty.
          It is highly recommended to login with: ssh -t
Restarting services
/usr/bin/rhcsh: line 123: gear: No such file or directory

有什么想法吗?

非常感谢。

编辑:

这是rhcsh脚本(脚本有300行,所以我上传到服务器):

http://www6.zippyshare.com/v/99209351/file.html

1 个答案:

答案 0 :(得分:1)

试试这个:

#!/bin/bash
gear restart --all-cartridges    # same as: ctl_all restart

ctl_all/usr/bin/gear脚本的包装函数。