Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Harald_Hansen
Advisor
Advisor

Adding cron jobs with quotes

One of the problems having gaia reinventing the wheel is the problem of adding simple commands using quotes.

For instance, a simple find command does not execute due to quotes being removed and wildcards executed in the wrong context.

Example, I want to clean up the /var/log/CPbackup/backups folder on a schedule.

The linux admin way is to do something like this in crontab:

00      05      *       *       *       find /var/log/CPbackup/backups/ -name "*.tgz" -type f -mtime +1 -delete -print

When adding this command with clish (add cron) the quotes disappear and the entire command changes fatally.

So one can "trick" clish by adding single quotes:

add cron job backup_cleanup command 'find /var/log/CPbackup/backups/ -name "*.tgz" -type f -mtime +1 -delete -print' recurrence daily time 05:00

 Though what happens if you do a `show configuration cron`?

harald-r80-40-mgmt> show configuration cron
add cron job backup_cleanup command "find /var/log/CPbackup/backups/ -name "*.tgz" -type f -mtime +1 -delete -print" recurrence daily time 07:45

The double quotes are back again!

So if you want to be safe, don't use commands in gaia cron, call a script. Also remember sk90441 (and sk167632).

A plea to the clish developers; if you really have to reinvent the wheel, at least make it round.

 

13 Replies
This widget could not be displayed.

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events