Hi all, I'm trying to do the simplest thing and it's becoming very frustrating. In my present company someone wrote a shell script to clean up files, rotate logs etc and I'm trying to replicate it's functionality with cfengine. Here is what I have so far...
body common control { bundlesequence => { "sys_cleanup" }; inputs => { "cfengine_stdlib.cf" }; } bundle agent sys_cleanup { vars: #System Log Files "rotate_daily_var_adm" slist => { "wtmp" }; "no_to_keep[wtmp]" string => "7"; "rotate_sunday_var_adm" slist => { "sudo.log", "sulog" }; "no_to_keep[sudo.log]" string => "4"; "no_to_keep[sulog]" string => "4"; "rotate_sunday_var_adm_cron" slist => { "log" }; "no_to_keep[log]" string => "14"; "rotate_sunday_etc_security" slist => { "failedlogin" }; "no_to_keep[failedlogin]" string => "8"; #Tivoli Logs "rotate_daily_var_tsm" slist => { "dsmsched.log" }; "no_to_keep[dsmsched.log]" string => "31"; files: "/var/adm/$(rotate_daily_var_adm)" comment => "Rotate daily logs and keep for length set in no_to_keep", rename => rotate("$(no_to_keep[$(rotate_daily_var_adm)])"); Sunday:: Hr05:: "/var/adm/$(rotate_sunday_var_adm)" comment => "Rotate the promises not kept logs each week", rename => rotate("$(no_to_keep[$(rotate_daily_var_adm)])"); Sunday:: Hr05:: "$(sys.workdir)/promise_summary.log" comment => "Rotate the promises not kept logs each week", rename => rotate("7"), action => if_elapsed("10000"); any:: "$(sys.workdir)/outputs" comment => "Garbage collection of any output files", delete => tidy, file_select => days_old("3"), depth_search => recurse("inf"); commands: "/bin/gzip /var/adm/$(rotate_daily_var_adm).*"; } The problem I'm having is with the regex for the gzip command. I get the following output community> -> Executing '/bin/gzip /var/adm/wtmp.*' ...(timeout=-678,owner=-1,group=-1) community> -> (Setting umask to 77) community> !! Finished command related to promiser "/bin/gzip /var/adm/wtmp.*" -- an error occurred (returned 1) community> Q: ".../bin/gzip /var/": gzip: /var/adm/wtmp.*: No such file or directory community> I: Last 1 quoted lines were generated by promiser "/bin/gzip /var/adm/wtmp.*" community> -> Completed execution of /bin/gzip /var/adm/wtmp.* If I run the command outside of cfengine it works a treat. [root@mascfpol01 tmp]# ls -l /var/adm/wtmp* -rw-r--r-- 1 root root 0 May 18 09:13 /var/adm/wtmp -rw-r--r-- 1 root root 27 May 18 09:13 /var/adm/wtmp.1.gz -rw-r--r-- 1 root root 27 May 18 09:08 /var/adm/wtmp.2.gz -rw-r--r-- 1 root root 27 May 18 09:07 /var/adm/wtmp.3.gz -rw-r--r-- 1 root root 27 May 18 09:03 /var/adm/wtmp.4.gz -rw-r--r-- 1 root root 27 May 18 09:03 /var/adm/wtmp.5.gz -rw-r--r-- 1 root root 27 May 18 09:03 /var/adm/wtmp.6.gz -rw-r--r-- 1 root root 27 May 18 09:02 /var/adm/wtmp.7.gz Any help would be appreciated... If anyone has any cleaner solutions for doing this that would also be appreciated. I looked at using transformations however I only want to gzip the rotated log not the current one so this doesn't seem suitable. I could distribute linux logrotate configuration however I'm dealing with AIX as well and logrotate doesn't exist. Cheers Steve
_______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine