Post Call Recording Script Question

Is it possible to put in any script to run after the Call Recording has ended? I have a script that I am using to use Rsync to move the recordings to an off site NAS. The script works fine, but if I put the path /home/asterisk/Backup/ nothing happens. I can get around this mostly by using a cron job that runs every minute. If it would work with the post that would be better I think


Is the script owned by asterisk?

ls -al /home/asterisk/Backup/

if not,

chown asterisk:asterisk /home/asterisk/Backup/


Yes owned by asterisk

Put the path where?

Advanced Settings

Add the path, make a call and get us the output from the full log for this call. Better yet:

  1. add the path, save.
  2. SSH to the system, do asterisk -rvvvvvvvvv
  3. Make call
  4. Get the output and put it here so we can see what actually happens.

== MixMonitor close filestream (mixed)
== Executing [/home/asterisk/Backup/]

So it is executing the script. What is in the script? Have you adding any logging for debugging/troubleshooting?

It isn’t running the script. I have rsync log and it shows no files created on the NAS. I checked the /var/spool/asterisk/monitor/ directory and they recorded files are there. here is my Rsync script

spawn rsync --verbose --log-file=/home/asterisk/Backup/rsynclog.txt --stats --progress --remove-source-files -zva /var/spool/asterisk/monitor/ [email protected]:/volume1/recordings
expect "[email protected]'s password:"
send "*********\n"
send "exit\n"
expect eof

Last run of Rsync from the log:

2024/06/03 07:29:01 [10944] Number of files: 21 (dir: 21)
2024/06/03 07:29:01 [10944] Number of created files: 0
2024/06/03 07:29:01 [10944] Number of deleted files: 0
2024/06/03 07:29:01 [10944] Number of regular files transferred: 0
2024/06/03 07:29:01 [10944] Total file size: 0 bytes
2024/06/03 07:29:01 [10944] Total transferred file size: 0 bytes
2024/06/03 07:29:01 [10944] Literal data: 0 bytes
2024/06/03 07:29:01 [10944] Matched data: 0 bytes
2024/06/03 07:29:01 [10944] File list size: 0
2024/06/03 07:29:01 [10944] File list generation time: 0.001 seconds
2024/06/03 07:29:01 [10944] File list transfer time: 0.000 seconds
2024/06/03 07:29:01 [10944] Total bytes sent: 581
2024/06/03 07:29:01 [10944] Total bytes received: 130
2024/06/03 07:29:01 [10944] sent 581 bytes  received 130 bytes  1,422.00 bytes/sec
2024/06/03 07:29:01 [10944] total size is 0  speedup is 0.00

If I run this from a cron job every minute it works fine.

does the asterisk user have ‘execute’ access to /bin/expect ?/

And the cron job is owned by what user? Asterisk is executing the script, whether or not it runs could be based on various reasons such as permissions and ownership.

When you’re in the Asterisk console you can do core set debut 10 and try again. That will kick out higher level debugging and might show what is happening when the script is being called on by Asterisk.

No, it is owned and the group is root.

I am thinking that the cronjob is owned by root.

Then add an ‘elevation’ in sudo or perhaps you could add an authorized key if using ssh as the transport for rsync

but are you not calling

? (post it’s content )

This is the whole script

I’m going to work on setting up an authorized key so I don’t have to fiddle with expect and permissions and such

Gotta wait on getting an access to the .ssh directory so I decided to change the owner and group of expect. So expect and all the files associated with it ate asterisk:asterisk with execute rights

I tried running core set debug 10 and got alot of data but when I tried to search for the it was not found