2015-10-15 7 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 не запускаются в интерактивном режиме, у вас могут быть разные пути. также может установить PATH в crontab. – 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 "объем продувки = $ volume yes" |/sbin/bconsole