Call an extension that goes to a custom context

Well unfortunately this is incorrect except for the fact that Asterisk aggressively consumes the call files. Here’s what I’ve done (server is UTC)

  1. su asterisk <-- drops me to the unprivileged asterisk user
  2. Create a test call file.
  3. Touch file 24 hours into the future
  4. cp file to /var/spool/asterisk/outgoing

Expectation: This file will not be triggered until 24 hours from its creation.
Result: Call immediately triggered and processed.

[asterisk@voice01 ~]$ whoami
asterisk
[asterisk@voice01 ~]$ ls -la test_1.call
-rw-r--r-- 1 asterisk asterisk 701 Dec 21 15:47 test_1.call
[asterisk@voice01 ~]$ touch -d "$(date -R -r test_1.call) + 24 hours" test_1.call
[asterisk@voice01 ~]$ ls -la test_1.call
-rw-r--r-- 1 asterisk asterisk 701 Dec 22  2019 test_1.call
[asterisk@voice01 ~]$ cp test_1.call /var/spool/asterisk/outgoing
[asterisk@voice01 ~]$ ls -la /var/spool/asterisk/outgoing
total 0
drwxrwxr-x.  2 asterisk asterisk   6 Dec 21 15:47 .
drwxrwxr-x. 14 asterisk asterisk 179 Dec 21 15:37 ..
[asterisk@voice01 ~]$ ls -la /var/spool/asterisk/outgoing_done/
total 8
drwxr-xr-x   2 asterisk asterisk  42 Dec 21 15:47 .
drwxrwxr-x. 14 asterisk asterisk 179 Dec 21 15:37 ..
-rw-r--r--   1 asterisk asterisk 751 Dec 21 15:47 test_1.call

Asterisk log:
[2019-12-21 15:47:48] VERBOSE[16091] pbx_spool.c: Attempting call on Local/13136517001@outbound-alerts/n for s@detect:1 (Retry 1)
[2019-12-21 15:47:48] VERBOSE[16091] dial.c: Called 13136517001@outbound-alerts/n

Now we do a mv instead.
[asterisk@voice01 ~]$ mv test_1.call /var/spool/asterisk/outgoing
[asterisk@voice01 ~]$ ls -la /var/spool/asterisk/outgoing
total 4
drwxrwxr-x. 2 asterisk asterisk 25 Dec 21 15:48 .
drwxrwxr-x. 14 asterisk asterisk 179 Dec 21 15:37 …
-rw-r–r-- 1 asterisk asterisk 701 Dec 22 2019 test_1.call

Now the call file is properly in the outgoing directory and will be triggered 24 hours from its creation.

If this is done as the root user and you chown the file to asterisk:asterisk and then cp it, it will end up in the outgoing directory owned by root:root. If you mv it, it ends up as asterisk:asterisk.

I do a lot of hotels which means a lot of wake up calls. Plus I also work with a national alerts carrier and there’s a lot of call files there too. Copying them causes more problems than you want like sending alerts immediately that were meant to go out at a specific time in the future.

What model of phone are you using?

You need to use ‘cp -p’ to preserve mtime (also ownership and mode but they are not really important), I apologise for omitting that detail.

edit:

Due diligence seems to support that if the file’s mod is at least 004 you can save all sorts of machinations if it’s mtime is >= now()+a few milliseconds before you cp -p it into …/outgoing

presumably those few milliseconds will increase significantly if you are cp -p 'ing over non-local file systems, but 500ms over sshfs between two disparately located DO machines seems solid, JM2CWAE

(ref: the source file ‘pbx/pbx_spool.c’)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.