On 10/23/24 10:59 AM, Justin Case wrote:
I used this in an admin job, but no verify/admin jobs older than 6mo got deleted:Runscript { RunsWhen = "Before" RunsOnClient = no Console = "delete from job where (type in ('V', 'D') or (type = 'B' and jobbytes = 0 and jobfiles = 0)) and starttime < now()-interval '6 months';" }
Hello Justin, That will not work as it currently is. The reason is that the `Console =` option is meant to send only bconsole specific commands to the Director.Also, I always recommend to not use the Console command at all and instead use the `Command =` option and point it to a small script for a few reasons:
- Any output from the Console command will be logged as `JobId: 0` and will not be logged to the catalog, and it is confusing to see random JobId: 0 log entries intermixed with other job log entries in the bacula log file.
- Using a script, all of its stdout will be logged in the job that called it, so you can report progress of a script simply by using the `echo` command in a shell script.
- You have full control of what happens in a script and the order of events. `Console =` cannot be guaranteed to run in the order specified in a Job (If you have more than one)
So, I would do something in a small script like: ----8<---- #!/bin/bash # First, SELECT using the same SQL command so you have in your job log what jobs were deleted echo -e "sql\nSELECT jobid, name from job ....\n\nquit\n" | bconsole # Next, DELETE using your SQL command but it needs to be passed to bconsole echo -e "sql\nDELETE from job where ....\n\nquit\n" | bconsole ----8<----Notice that `echo -e` is used. This allows us to send multiple commands using the `\n` (line feed). We need this because we have to first put bconsole into its `sql` mode so we can send the SELECT and DELETE SQL commands.
Also notice there are two `\n` after the SQL commands and before the quit command. This isso we "Terminate query mode with a blank line." as the bconsole sql command tells us when we enter that mode. :)
Hope this helps, Bill -- Bill Arlofski w...@protonmail.com
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Bacula-users mailing list Bacula-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-users