-1

I have a script:

-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

If I run it manually it runs.

If I put the script to crontab it doesn't run, however the log says it ran.

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

The schedule:

07 16 * * * /backup/purge.sh

If I run manually:

/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.
JNevill
  • 46,980
  • 4
  • 38
  • 63
Badb0y
  • 331
  • 2
  • 21
  • 1
    Might be OT here, but make sure `bconsole` is in the path, or provide the full path in the script. since cron jobs do not run interactive, you can have different paths set. can also set PATH in crontab. – Doon Oct 15 '15 at 15:48
  • Solved, full path needed in the script. – Badb0y Oct 15 '15 at 15:51
  • @Badb0y add a answer with the solution since you've managed to fix it. – AJefferiss Oct 15 '15 at 15:54
  • 1
    This environment issue is point 6 in the Debugging crontab section of the crontab tag [info wiki](http://stackoverflow.com/tags/crontab/info). – Etan Reisner Oct 15 '15 at 16:09

1 Answers1

0

bconsole hasn't been in the PATH so I used full path for the bconsole command like this:

!/bin/bash

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

Community
  • 1
  • 1
Badb0y
  • 331
  • 2
  • 21