2015-10-15 250 views
-1

我有一個腳本:腳本不運行

-rwx------. 1 root root 135 Oct 15 12:00 /backup/purge.sh 


#!/bin/bash 
volume=`echo "list volumes" | bconsole|grep -i "Append\|Full"|awk '{print $4}'` 
echo "purge volume=$volume yes" | bconsole 

如果我手動運行它,它運行。

如果我把腳本放到crontab中,它不會運行,但是日誌說它運行了。

Oct 15 16:07:01 sdfdsfdsf CROND[36326]: (root) CMD (/backup/purge.sh) 

時間表:

07 16 * * * /backup/purge.sh 

如果我手動運行:

/backup/purge.sh 
Connecting to Director weewr:9101 
1000 OK: 1 werewrewrewr Version: 7.0.5 (28 July 2014) 
Enter a period to cancel a command. 
purge volume=Vol-0001 yes 

This command can be DANGEROUS!!! 

It purges (deletes) all Files from a Job, 
JobId, Client or Volume; or it purges (deletes) 
all Jobs from a Client or Volume without regard 
to retention periods. Normally you should use the 
PRUNE command, which respects retention periods. 
Automatically selected Catalog: MyCatalog 
Using Catalog "MyCatalog" 
1 File on Volume "Vol-0001" purged from catalog. 
There are no more Jobs associated with Volume "Vol-0001". Marking it purged. 
+1

可能是OT,但要確保'bconsole'在路徑中,或者在腳本中提供完整路徑。由於cron作業不能以交互方式運行,因此可以設置不同的路徑。也可以在crontab中設置PATH。 – Doon

+0

已解決,腳本中需要的完整路徑。 – Badb0y

+0

@ Badb0y自解決問題之後就爲解決方案添加答案。 – AJefferiss

回答

0

bconsole一直沒有在PATH所以我用完整路徑是這樣的bconsole命令:

!/ bin/bash

volume = echo "list volumes" | /sbin/bconsole|grep -i "Append\|Full"|awk '{print $4}' echo「purge volume = $ volume yes」|/sbin/bconsole