2014-09-12 303 views
1

我試圖用cron重新啓動服務器。我發現這個鏈接:使用Cron的Shell腳本無法執行shell命令

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

+0

似乎在/ usr/bin/rhcsh文件中出現了問題。你能粘貼它的內容嗎? – 2014-09-12 16:37:58

+0

嗨Tomasz,問題在於cron安裝在OpenShift(https://www.openshift.com)基礎架構上,並且腳本無法修改。如果你仍然想看到腳本可以將其添加到主帖子。 – Alberto 2014-09-12 18:36:06

+0

仍然可能有幫助。這個問題可能不在腳本本身,而是在它使用的東西中,也許是一些環境變量。我特別好奇第一條錯誤發生在第7行的是什麼。 – 2014-09-13 10:08:09

回答

1

試試這個:

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

ctl_all/usr/bin/gear腳本的包裝函數。