I have the following script. Not sure what I am missing. I simply want to delete all logs older than 7 days
#!/bin/bash
# find and remove files last modified over 7 days ago from call recording directory
/usr/bin/find /var/spool/asterisk/monitor -type f -mtime +7 -exec rm -f {} \;
# remove empty directories
/usr/bin/find /var/spool/asterisk/monitor -type d -empty -delete
dicko
(dicko)
August 4, 2020, 12:27am
#2
what happens when you run that script?
where do run ot from?
as what user?
what permissions does have?
I am running it as root. Owner and group are asterisk. Permissions 755
dicko
(dicko)
August 4, 2020, 12:45am
#4
. . . .what happens when you run that script? . . .
bash -x /path/and/name/of/your.script
sorry. It doesnβt work either. I am pretty sure it did at one time.
dicko
(dicko)
August 4, 2020, 12:48am
#6
Yes, but what gets printed to the terminal, (no mind-readers here )
no errors. Is there a way to log it?
dicko
(dicko)
August 4, 2020, 1:37am
#8
Copy and paste the poutput of the bash -x command from a shell. βno errorsβ is not likely what it printed.
billsimon
(Bill Simon)
August 4, 2020, 1:44am
#9
You are pointing to the call recordings directory. If you want to delete logs, point at /var/log/asterisk. Better, use logrotate to do the work.
now it appears all of a sudden to work when I run manually. Maybe the crontab isnβt running which I have is:
0 0 * * * ~/scripts/archive.sh
Bash -x gives:
[[email protected] ~]# bash -x
+ bash -x
+ alias βrm=rm -iβ
+ alias βcp=cp -iβ
+ alias βmv=mv -iβ
+ β[β -f /etc/bashrc β]β
+ . /etc/bashrc
++ β[β β\s-\v$ β β]β
++ β[β -z ββ β]β
++ case $TERM in
++ β[β -e /etc/sysconfig/bash-prompt-xterm β]β
++ β[β 0 -ge 3405 β]β
++ PROMPT_COMMAND=βprintf β\033]0;%[email protected] %s:%s\007β β${USER}β "${HOSTNAME%%.}" β${PWD/#$HOME/~}ββ
++ shopt -s histappend
++ history -a
++ shopt -s checkwinsize
++ β[β '\s-\v$ β = β\s-\v$ β β]β
++ PS1=β[\[email protected] \h \W]$ β
++ shopt -q login_shell
++ β[β 0 -gt 199 β]β
++ umask 022
++ SHELL=/bin/bash
++ for i in '/etc/profile.d/ .shβ
++ β[β -r /etc/profile.d/256term.sh β]β
++ β[β β[\[email protected] \h \W]$ β β]β
++ . /etc/profile.d/256term.sh
+++ local256=
+++ β[β -n ββ β]β
+++ β[β -n ββ β]β
+++ unset local256
++ for i in β/etc/profile.d/.shβ
++ β[β -r /etc/profile.d/colorgrep.sh β]β
++ β[β '[\[email protected] \h \W]$ β β]β
++ . /etc/profile.d/colorgrep.sh
+++ /usr/libexec/grepconf.sh -c
+++ alias βgrep=grep --color=autoβ
+++ alias βegrep=egrep --color=autoβ
+++ alias βfgrep=fgrep --color=autoβ
++ for i in '/etc/profile.d/ .shβ
++ β[β -r /etc/profile.d/colorls.sh β]β
++ β[β β[\[email protected] \h \W]$ β β]β
++ . /etc/profile.d/colorls.sh
+++ β[β β!β -t 0 β]β
+++ β[β -z ββ β]β
+++ alias βll=ls -lβ
+++ alias βl.=ls -d .β
+++ INCLUDE=
+++ COLORS=
+++ for colors in β"$HOME/.dir_colors.$TERM"β β"$HOME/.dircolors.$TERM"β β"$HOME/.dir_colors"β β"$HOME/.dircolors"β
+++ β[β -e /root/.dir_colors.xterm-256color β]β
+++ for colors in β"$HOME/.dir_colors.$TERM"β β"$HOME/.dircolors.$TERM"β β"$HOME/.dir_colors"β β"$HOME/.dircolors"β
+++ β[β -e /root/.dircolors.xterm-256color β]β
+++ for colors in β"$HOME/.dir_colors.$TERM"β β"$HOME/.dircolors.$TERM"β β"$HOME/.dir_colors"β β"$HOME/.dircolors"β
+++ β[β -e /root/.dir_colors β]β
+++ for colors in β"$HOME/.dir_colors.$TERM"β β"$HOME/.dircolors.$TERM"β β"$HOME/.dir_colors"β β"$HOME/.dircolors"β
+++ β[β -e /root/.dircolors β]β
+++ β[β -z ββ β]β
+++ β[β -e /etc/DIR_COLORS.xterm-256color β]β
+++ β[β -z ββ β]β
+++ β[β -e /etc/DIR_COLORS.256color β]β
++++ /usr/bin/tty -s
++++ /usr/bin/tput colors
+++ β[β x256 = x256 β]β
+++ COLORS=/etc/DIR_COLORS.256color
+++ β[β -z /etc/DIR_COLORS.256color β]β
+++ β[β -n /etc/DIR_COLORS.256color β]β
+++ β[β -e ββ β]β
++++ /usr/bin/dircolors --sh /etc/DIR_COLORS.256color
+++ eval βLS_COLORS=ββ'rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34: .tar=38;5;9:.tgz=38;5;9: .arc=38;5;9:.arj=38;5;9: .taz=38;5;9:.lha=38;5;9: .lz4=38;5;9:.lzh=38;5;9: .lzma=38;5;9:.tlz=38;5;9: .txz=38;5;9:.tzo=38;5;9: .t7z=38;5;9:.zip=38;5;9: .z=38;5;9:.Z=38;5;9: .dz=38;5;9:.gz=38;5;9: .lrz=38;5;9:.lz=38;5;9: .lzo=38;5;9:.xz=38;5;9: .bz2=38;5;9:.bz=38;5;9: .tbz=38;5;9:.tbz2=38;5;9: .tz=38;5;9:.deb=38;5;9: .rpm=38;5;9:.jar=38;5;9: .war=38;5;9:.ear=38;5;9: .sar=38;5;9:.rar=38;5;9: .alz=38;5;9:.ace=38;5;9: .zoo=38;5;9:.cpio=38;5;9: .7z=38;5;9:.rz=38;5;9: .cab=38;5;9:.jpg=38;5;13: .jpeg=38;5;13:.gif=38;5;13: .bmp=38;5;13:.pbm=38;5;13: .pgm=38;5;13:.ppm=38;5;13: .tga=38;5;13:.xbm=38;5;13: .xpm=38;5;13:.tif=38;5;13: .tiff=38;5;13:.png=38;5;13: .svg=38;5;13:.svgz=38;5;13: .mng=38;5;13:.pcx=38;5;13: .mov=38;5;13:.mpg=38;5;13: .mpeg=38;5;13:.m2v=38;5;13: .mkv=38;5;13:.webm=38;5;13: .ogm=38;5;13:.mp4=38;5;13: .m4v=38;5;13:.mp4v=38;5;13: .vob=38;5;13:.qt=38;5;13: .nuv=38;5;13:.wmv=38;5;13: .asf=38;5;13:.rm=38;5;13: .rmvb=38;5;13:.flc=38;5;13: .avi=38;5;13:.fli=38;5;13: .flv=38;5;13:.gl=38;5;13: .dl=38;5;13:.xcf=38;5;13: .xwd=38;5;13:.yuv=38;5;13: .cgm=38;5;13:.emf=38;5;13: .axv=38;5;13:.anx=38;5;13: .ogv=38;5;13:.ogx=38;5;13: .aac=38;5;45:.au=38;5;45: .flac=38;5;45:.mid=38;5;45: .midi=38;5;45:.mka=38;5;45: .mp3=38;5;45:.mpc=38;5;45: .ogg=38;5;45:.ra=38;5;45: .wav=38;5;45:.axa=38;5;45: .oga=38;5;45:.spx=38;5;45: .xspf=38;5;45:βββ;
export LS_COLORSβ
++++ LS_COLORS=βrs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:.tar=38;5;9: .tgz=38;5;9:.arc=38;5;9: .arj=38;5;9:.taz=38;5;9: .lha=38;5;9:.lz4=38;5;9: .lzh=38;5;9:.lzma=38;5;9: .tlz=38;5;9:.txz=38;5;9: .tzo=38;5;9:.t7z=38;5;9: .zip=38;5;9:.z=38;5;9: .Z=38;5;9:.dz=38;5;9: .gz=38;5;9:.lrz=38;5;9: .lz=38;5;9:.lzo=38;5;9: .xz=38;5;9:.bz2=38;5;9: .bz=38;5;9:.tbz=38;5;9: .tbz2=38;5;9:.tz=38;5;9: .deb=38;5;9:.rpm=38;5;9: .jar=38;5;9:.war=38;5;9: .ear=38;5;9:.sar=38;5;9: .rar=38;5;9:.alz=38;5;9: .ace=38;5;9:.zoo=38;5;9: .cpio=38;5;9:.7z=38;5;9: .rz=38;5;9:.cab=38;5;9: .jpg=38;5;13:.jpeg=38;5;13: .gif=38;5;13:.bmp=38;5;13: .pbm=38;5;13:.pgm=38;5;13: .ppm=38;5;13:.tga=38;5;13: .xbm=38;5;13:.xpm=38;5;13: .tif=38;5;13:.tiff=38;5;13: .png=38;5;13:.svg=38;5;13: .svgz=38;5;13:.mng=38;5;13: .pcx=38;5;13:.mov=38;5;13: .mpg=38;5;13:.mpeg=38;5;13: .m2v=38;5;13:.mkv=38;5;13: .webm=38;5;13:.ogm=38;5;13: .mp4=38;5;13:.m4v=38;5;13: .mp4v=38;5;13:.vob=38;5;13: .qt=38;5;13:.nuv=38;5;13: .wmv=38;5;13:.asf=38;5;13: .rm=38;5;13:.rmvb=38;5;13: .flc=38;5;13:.avi=38;5;13: .fli=38;5;13:.flv=38;5;13: .gl=38;5;13:.dl=38;5;13: .xcf=38;5;13:.xwd=38;5;13: .yuv=38;5;13:.cgm=38;5;13: .emf=38;5;13:.axv=38;5;13: .anx=38;5;13:.ogv=38;5;13: .ogx=38;5;13:.aac=38;5;45: .au=38;5;45:.flac=38;5;45: .mid=38;5;45:.midi=38;5;45: .mka=38;5;45:.mp3=38;5;45: .mpc=38;5;45:.ogg=38;5;45: .ra=38;5;45:.wav=38;5;45: .axa=38;5;45:.oga=38;5;45: .spx=38;5;45:.xspf=38;5;45:β
++++ export LS_COLORS
+++ β[β -z 'rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34: .tar=38;5;9:.tgz=38;5;9: .arc=38;5;9:.arj=38;5;9: .taz=38;5;9:.lha=38;5;9: .lz4=38;5;9:.lzh=38;5;9: .lzma=38;5;9:.tlz=38;5;9: .txz=38;5;9:.tzo=38;5;9: .t7z=38;5;9:.zip=38;5;9: .z=38;5;9:.Z=38;5;9: .dz=38;5;9:.gz=38;5;9: .lrz=38;5;9:.lz=38;5;9: .lzo=38;5;9:.xz=38;5;9: .bz2=38;5;9:.bz=38;5;9: .tbz=38;5;9:.tbz2=38;5;9: .tz=38;5;9:.deb=38;5;9: .rpm=38;5;9:.jar=38;5;9: .war=38;5;9:.ear=38;5;9: .sar=38;5;9:.rar=38;5;9: .alz=38;5;9:.ace=38;5;9: .zoo=38;5;9:.cpio=38;5;9: .7z=38;5;9:.rz=38;5;9: .cab=38;5;9:.jpg=38;5;13: .jpeg=38;5;13:.gif=38;5;13: .bmp=38;5;13:.pbm=38;5;13: .pgm=38;5;13:.ppm=38;5;13: .tga=38;5;13:.xbm=38;5;13: .xpm=38;5;13:.tif=38;5;13: .tiff=38;5;13:.png=38;5;13: .svg=38;5;13:.svgz=38;5;13: .mng=38;5;13:.pcx=38;5;13: .mov=38;5;13:.mpg=38;5;13: .mpeg=38;5;13:.m2v=38;5;13: .mkv=38;5;13:.webm=38;5;13: .ogm=38;5;13:.mp4=38;5;13: .m4v=38;5;13:.mp4v=38;5;13: .vob=38;5;13:.qt=38;5;13: .nuv=38;5;13:.wmv=38;5;13: .asf=38;5;13:.rm=38;5;13: .rmvb=38;5;13:.flc=38;5;13: .avi=38;5;13:.fli=38;5;13: .flv=38;5;13:.gl=38;5;13: .dl=38;5;13:.xcf=38;5;13: .xwd=38;5;13:.yuv=38;5;13: .cgm=38;5;13:.emf=38;5;13: .axv=38;5;13:.anx=38;5;13: .ogv=38;5;13:.ogx=38;5;13: .aac=38;5;45:.au=38;5;45: .flac=38;5;45:.mid=38;5;45: .midi=38;5;45:.mka=38;5;45: .mp3=38;5;45:.mpc=38;5;45: .ogg=38;5;45:.ra=38;5;45: .wav=38;5;45:.axa=38;5;45: .oga=38;5;45:.spx=38;5;45: .xspf=38;5;45:β β]β
+++ /usr/bin/grep -qi β^COLOR.noneβ /etc/DIR_COLORS.256color
+++ unset TMP COLORS INCLUDE
+++ alias βll=ls -l --color=autoβ
+++ alias 'l.=ls -d . --color=autoβ
+++ alias βls=ls --color=autoβ
++ for i in β/etc/profile.d/.shβ
++ β[β -r /etc/profile.d/lang.sh β]β
++ β[β '[\[email protected] \h \W]$ β β]β
++ . /etc/profile.d/lang.sh
+++ sourced=0
+++ β[β -n en_US.UTF-8 β]β
+++ saved_lang=en_US.UTF-8
+++ β[β -f /root/.i18n β]β
+++ LANG=en_US.UTF-8
+++ unset saved_lang
+++ β[β 0 = 1 β]β
+++ unset sourced
+++ unset langfile
++ for i in '/etc/profile.d/ .shβ
++ β[β -r /etc/profile.d/less.sh β]β
++ β[β β[\[email protected] \h \W]$ β β]β
++ . /etc/profile.d/less.sh
+++ β[β -x /usr/bin/lesspipe.sh β]β
+++ export βLESSOPEN=||/usr/bin/lesspipe.sh %sβ
+++ LESSOPEN=β||/usr/bin/lesspipe.sh %sβ
++ for i in β/etc/profile.d/*.shβ
++ β[β -r /etc/profile.d/motd.sh β]β
++ β[β β[\[email protected] \h \W]$ β β]β
++ . /etc/profile.d/motd.sh
+++ RUNAS=asterisk
++++ /usr/bin/id -u
+++ β[β 0 == 0 β]β
+++ SU=β/bin/su asterisk -cβ
+++ β[β '[\[email protected] \h \W]$ β β]β
+++ β[β -L /usr/sbin/fwconsole β]β
++++ /bin/readlink /usr/sbin/fwconsole
+++ FWCONSOLE=/var/lib/asterisk/bin/fwconsole
+++ β[β -e /var/lib/asterisk/bin/fwconsole β]β
+++ β[β β/bin/su asterisk -cβ β]β
+++ /bin/su asterisk -c β/var/lib/asterisk/bin/fwconsole motdβ
______ ______ ______ __ __
| | | ___ | ___ \ \ / /
| | _ __ ___ ___ | | / /| | / / \ V /
| | | '__| / _ \ / _ | __/ | ___ \ /
| | | | | __/| __/| | | | / // /^\
_| || _| _ |_| _ __/ / /
Current Network Configuration
+-----------+-------------------+--------------------------+
| Interface | MAC Address | IP Addresses |
+-----------+-------------------+--------------------------+
| eth0 | 00:00:00:00:00:00 | x.x.x.x |
| | | fe80::xxx:xxxx:xxxx:xxxx |
+-----------+-------------------+--------------------------+
Please note most tasks should be handled through the GUI.
You can access the GUI by typing one of the above IPs in to your web browser.
For support please visit:
http://www.freepbx.org/support-and-professional-services
++ for i in '/etc/profile.d/*.sh'
++ '[' -r /etc/profile.d/vim.sh ']'
++ '[' '[\[email protected] \h \W]\$ ' ']'
++ . /etc/profile.d/vim.sh
+++ '[' -n '4.2.46(2)-release' -o -n '' -o -n '' ']'
+++ '[' -x /usr/bin/id ']'
++++ /usr/bin/id -u
+++ ID=0
+++ '[' -n 0 -a 0 -le 200 ']'
+++ return
++ for i in '/etc/profile.d/*.sh'
++ '[' -r /etc/profile.d/which2.sh ']'
++ '[' '[\[email protected] \h \W]\$ ' ']'
++ . /etc/profile.d/which2.sh
+++ alias 'which=alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
++ for i in '/etc/profile.d/*.sh'
++ '[' -r /etc/profile.d/z001-updates.sh ']'
++ '[' '[\[email protected] \h \W]\$ ' ']'
++ . /etc/profile.d/z001-updates.sh
+++ '[' '!' -e /etc/sangoma/schmooze.zl -a '!' -e /etc/sangoma/sangoma.zl ']'
+++ '[' '!' xterm-256color -o xterm-256color == dumb ']'
+++ WIDTH=60
++++ tput bold
++++ tput smul
+++ BOLD=''
++++ tput sgr0
+++ NORMAL=''
++++ tput setaf 1
+++ RED=''
++++ tput setaf 2
+++ GREEN=''
++++ tput setaf 3
+++ YELLOW=''
+++ '[' '' == update ']'
+++ '[' '' == unicode ']'
++++ eval printf %.0s- '{1..60}'
+++++ printf %.0s- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
+++ FULLWIDTH=------------------------------------------------------------
++++ eval printf '%.0s\ ' '{1..60}'
+++++ printf '%.0s ' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
+++ BLANK='| |'
+++ '[' '' == unicode ']'
+++ echo -e +------------------------------------------------------------+
+------------------------------------------------------------+
+++ show_updates
++++ get_cacheage
+++++ head -1
+++++ ls --color=auto -t /var/cache/yum/x86_64/7/sng-pkgs/cachecookie
++++ COOKIEFILE=/var/cache/yum/x86_64/7/sng-pkgs/cachecookie
++++ '[' '!' -s /var/cache/listonline -o '!' /var/cache/yum/x86_64/7/sng-pkgs/cachecookie ']'
+++++ stat -c %Y /var/cache/yum/x86_64/7/sng-pkgs/cachecookie
++++ S=1596585066
+++++ date +%s
++++ echo 462
++++ return
+++ AGE=462
+++ '[' 462 == ERROR ']'
+++ '[' 462 -gt 86400 ']'
+++ '[' 462 -gt 3600 ']'
+++ system_updates
++++ wc -l /var/cache/check-update
++++ awk ' { print $1 }'
+++ UPDATES=0
+++ '[' '!' 0 ']'
+++ '[' 0 -eq 0 ']'
+++ boxecho 'Your system is currently up to date!' 11
+++ LINE='Your system is currently up to date!'
+++ ANSIPADDING=11
+++ PADDING=12
+++ '[' 11 ']'
+++ PADDING=23
+++ '[' 23 -lt 0 ']'
+++ '[' '' == unicode ']'
++++ eval printf '%.0s\ ' '{1..23}'
+++++ printf '%.0s ' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
+++ echo -e '| Your system is currently up to date! |'
| Your system is currently up to date! |
+++ pbx_updates
++++ tail -1 /var/cache/listonline
+++ LASTLINE=+----------------------+------------+-------------------------------------------+-------------+
+++ [[ +----------------------+------------+-------------------------------------------+-------------+ != *\-\-\-\-\-\-\-\-\-\-* ]]
++++ wc -l
++++ grep --color=auto '| Broken' /var/cache/listonline
+++ BROKEN=0
++++ wc -l
++++ grep --color=auto '| Not Installed' /var/cache/listonline
+++ NOTINSTALLED=4
++++ grep --color=auto '| Online upgrade available' /var/cache/listonline
++++ wc -l
+++ UPGRADEAVAIL=0
++++ wc -l
++++ grep --color=auto '| Disabled' /var/cache/listonline
+++ DISABLED=0
+++ '[' 0 -eq 0 ']'
+++ boxecho 'Your PBX is up to date.' 11
+++ LINE='Your PBX is up to date.'
+++ ANSIPADDING=11
+++ PADDING=25
+++ '[' 11 ']'
+++ PADDING=36
+++ '[' 36 -lt 0 ']'
+++ '[' '' == unicode ']'
++++ eval printf '%.0s\ ' '{1..36}'
+++++ printf '%.0s ' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
+++ echo -e '| Your PBX is up to date. |'
| Your PBX is up to date. |
+++ '[' 0 -ne 0 ']'
+++ DIS=
+++ '[' 4 -ne 0 ']'
++++ plural 4
++++ '[' 4 -eq 1 ']'
++++ echo s
+++ NI='4 Uninstalled modules'
+++ '[' '' -a '4 Uninstalled modules' ']'
+++ '[' '' ']'
+++ '[' '4 Uninstalled modules' ']'
+++ boxecho ' Also 4 Uninstalled modules.'
+++ LINE=' Also 4 Uninstalled modules.'
+++ ANSIPADDING=
+++ PADDING=30
+++ '[' '' ']'
+++ '[' 30 -lt 0 ']'
+++ '[' '' == unicode ']'
++++ eval printf '%.0s\ ' '{1..30}'
+++++ printf '%.0s ' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
+++ echo -e '| Also 4 Uninstalled modules. |'
| Also 4 Uninstalled modules. |
+++ '[' 0 -ne 0 ']'
+++ '[' '' == unicode ']'
+++ echo -e +------------------------------------------------------------+
+------------------------------------------------------------+
++ unset i
++ unset -f pathmunge
++ printf '\033]0;%[email protected] %s:%s\007' root PBX '~'
am I supposed to give crontab asterisk rights maybe?
billsimon
(Bill Simon)
August 5, 2020, 12:13am
#11
You are not making a lot of sense here. What are you trying to do? What is all this output supposed to be telling us?
I am just posting what bash -x gave me. No idea what its for lol. I just want to delete those logs and check nightly. Works manually
billsimon
(Bill Simon)
August 5, 2020, 12:17am
#13
You keep saying logs but do you mean call recordings? Because that is what the commands will actually delete.
correct the recordings and logs. Sorry I had that added in my first script, but want to do both
dicko
(dicko)
August 5, 2020, 1:34am
#15
Please read the instructions again carefully !!
bash -x
opens a bash shell noisily.
bash -x scriptname
opens a shell script named βscriptnameβ noisily in a bash shell.
Cron jobs are run by default in your βshβ environment (not bash) , as such your assumption of β~/β needs to be explicitly rooted to the cron user the job belongs to, all jobs should be better tested with
su (youruser) -c β/like/pulling/teeth.shβ
1 Like
cynjut
(Dave Burgess)
August 6, 2020, 2:29pm
#16
sentinelace:
-mtime +7
Check the syntax for the mtime option. While I have been helping my inlaws move the the past two weeks, Iβm thinking that doesnβt look like (Iβm thinking β-7dβ instead of +7) but of course, after that long away, it could all just be a dream.
[[email protected] scripts]# bash -x archive.sh
/usr/bin/find /var/spool/asterisk/monitor -type f -mtime +7 -exec rm -f β{}β β;β
/usr/bin/find /var/spool/asterisk/monitor -type d -empty -delete
[[email protected] scripts]#
dicko
(dicko)
August 6, 2020, 7:12pm
#18
Better to use -delete instead of βexec rm -f . . . .β as you do for your directories because it is easy to get your βquotingβ un escaped (β{}β should be just {}) perhaps the forum mangled your post but that β;β at the end should be \;
Be that as it may, non-working quotes are other bad sysntax would have shown up if the script was run through bash -x
/usr/bin/find /var/spool/asterisk/monitor -type f -mtime +7
returned and of course
/usr/bin/find /var/spool/asterisk/monitor -type d -empty
would show any empty directories.
So before you try and delete anything make sure there is something to be deleted or you will be disappointed.
But again, these will be recorded calls older than 7 days, not logs
mbrooks
(Matt Brooks)
August 6, 2020, 11:32pm
#19
Out of curiosity, any reason for not using the logrotate application in linux?
Iβm a google programmer lol. Not my thing but whatever makes it work. The script runs fine as stated and works but the crontab doesnβt seem to launch it