• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to use GotoIfTime Application on Asterisk Dialplan context

  • 00:30 lsb_release -a
  • 00:45 systemctl status asterisk
  • 01:08 cd /etc/asterisk/
  • 01:17 vim extensions.conf
  • 06:00 asterisk -rvvvvvvvvvvvvvvvvvvvvvvv
  • 06:07 dialplan reload
  • 06:59 vim extensions.conf
  • 07:17 asterisk -rvvvvvvvvvvvvvvvvvvvvvvv
  • 07:21 dialplan reload
{{postValue.id}}

To Use GotoIfTime Application On Asterisk Dialplan Context

GotoIfTime application is very identical to the GotoIf application, the difference is that allows you to jump to another extension, context, or priority if the current time matches the specified one.

Procedure

Step 1: Check the OS version by using the below command

root@linuxhelp1:~# lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:    22.04
Codename:    jammy

Step 2: Check the status of the Asterisk by using the below command

root@linuxhelp1:~# systemctl status asterisk
● asterisk.service - LSB: Asterisk PBX
     Loaded: loaded (/etc/init.d/asterisk; generated)
     Active: active (running) since Sun 2023-08-06 07:11:56 IST; 1h 9min ago
       Docs: man:systemd-sysv-generator(8)
    Process: 1418 ExecStart=/etc/init.d/asterisk start (code=exited, status=0/SUCCESS)
      Tasks: 71 (limit: 4537)
     Memory: 131.2M
        CPU: 1min 45.008s
     CGroup: /system.slice/asterisk.service
             └─1461 /usr/sbin/asterisk
Aug 06 07:11:56 linuxhelp1 systemd[1]: Starting LSB: Asterisk PBX...
Aug 06 07:11:56 linuxhelp1 asterisk[1418]:  * Starting Asterisk PBX: asterisk
Aug 06 07:11:56 linuxhelp1 asterisk[1418]:    ...done.
Aug 06 07:11:56 linuxhelp1 systemd[1]: Started LSB: Asterisk PBX.
Aug 06 07:12:03 linuxhelp1 asterisk[1461]: radcli: rc_read_config: rc_read_config: can't open /etc>
Aug 06 07:12:03 linuxhelp1 asterisk[1461]: radcli: rc_read_config: rc_read_config: can't open /etc>

Step 3: Move to the asterisk directory by using the below command

root@linuxhelp1:~# cd /etc/asterisk/

Step 4: Edit the extensions.conf file by using the below command

root@linuxhelp1:/etc/asterisk# vim extensions.conf
Add the following lines
[internal]
exten => _XXX,1,NoOp(How to use GotoIfTime Application)
exten => _XXX,2,GotoIFTime(08:00-08:30,mon-fri,1-31,jan-dec,Asia/Kolkata?open:close)
exten => _XXX,n(open),Playback(hello)
exten => _XXX,n(close),Hangup()

Step 5: Login to the Asterisk CLI mode by using the below command

root@linuxhelp1:/etc/asterisk# asterisk -rvvvvvvvvvvvvvvvvvvvvvvv
Asterisk 20.3.1, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.3.1 currently running on linuxhelp1 (pid = 1461)

Step 6: Reload the dialplan by using the below command

linuxhelp1*CLI> dialplan reload
Dialplan reloaded.
    -- Including switch 'DUNDi/e164' in context 'ael-dundi-e164-switch'
    -- Including switch 'Lua/' in context 'default'
    -- Including switch 'Lua/' in context 'demo'
    -- Including switch 'Lua/' in context 'public'
    -- Including switch 'Lua/' in context 'local'
    -- Time to scan old dialplan and merge leftovers back into the new: 0.000351 sec
    -- Time to restore hints and swap in new dialplan: 0.000004 sec
    -- Time to delete the old dialplan: 0.000103 sec
    -- Total time merge_contexts_delete: 0.000458 sec
    -- pbx_config successfully loaded 27 contexts (enable debug for details).

Output of the GotoIfTime Application if the condition is false

    -- Executing [168@internal:1] NoOp("PJSIP/167-00000000", "How to use GotoIfTime Application") in new stack
    -- Executing [168@internal:2] GotoIfTime("PJSIP/167-00000000", "08:00-08:30,mon-fri,1-31,jan-dec,Asia/Kolkata?open:close") in new stack
    -- Goto (internal,168,4)
    -- Executing [168@internal:4] Hangup("PJSIP/167-00000000", "") in new stack
  == Spawn extension (internal, 168, 4) exited non-zero on 'PJSIP/167-00000000'
linuxhelp1*CLI>
Disconnected from Asterisk server
Asterisk cleanly ending (0).
Executing last minute clean-ups

Step 7: Edit the extensions.conf file for true condition by using the below command

root@linuxhelp1:/etc/asterisk# vim extensions.conf
Add the following lines
[internal]
exten => _XXX,1,NoOp(How to use GotoIfTime Application)
exten => _XXX,2,GotoIFTime(08:00-08:45,mon-fri,1-31,jan-dec,Asia/Kolkata?open:close)
exten => _XXX,n(open),Playback(hello)
exten => _XXX,n(close),Hangup()

Step 8: Again, login to the Asterisk CLI mode by using the below command

root@linuxhelp1:/etc/asterisk# asterisk -rvvvvvvvvvvvvvvvvvvvvvvv
Asterisk 20.3.1, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.3.1 currently running on linuxhelp1 (pid = 1461)

Step 9: Reload the dialplan by using the below command

linuxhelp1*CLI> dialplan reload
Dialplan reloaded.
    -- Including switch 'Lua/' in context 'local'
    -- Including switch 'Lua/' in context 'public'
    -- Including switch 'Lua/' in context 'demo'
    -- Including switch 'Lua/' in context 'default'
    -- Including switch 'DUNDi/e164' in context 'ael-dundi-e164-switch'
    -- Time to scan old dialplan and merge leftovers back into the new: 0.000240 sec
    -- Time to restore hints and swap in new dialplan: 0.000005 sec
    -- Time to delete the old dialplan: 0.000048 sec
    -- Total time merge_contexts_delete: 0.000293 sec
    -- pbx_config successfully loaded 27 contexts (enable debug for details).

Output of the GotoIfTime Application if the condition is true

 -- Executing [168@internal:1] NoOp("PJSIP/167-00000004", "How to use GotoIfTime Application") in new stack
    -- Executing [168@internal:2] GotoIfTime("PJSIP/167-00000004", "08:00-08:45,mon-fri,1-31,jan-dec,Asia/Kolkata?open:close") in new stack
    -- Goto (internal,168,3)
    -- Executing [168@internal:3] Playback("PJSIP/167-00000004", "hello") in new stack
       > 0x7fd4c4013960 -- Strict RTP learning after remote address set to: 192.168.6.101:4006
    -- <PJSIP/167-00000004> Playing 'hello.ulaw' (language 'en')
       > 0x7fd4c4013960 -- Strict RTP switching to RTP target address 192.168.6.101:4006 as source
    -- Executing [168@internal:4] Hangup("PJSIP/167-00000004", "") in new stack
  == Spawn extension (internal, 168, 4) exited non-zero on 'PJSIP/167-00000004'

Conclusion:

By this How to use GotoIfTime Application on Asterisk Dialplan context has come to an end.

Tags:
elijah
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is the function of the GotoIfTime application?

A

Conditional Goto based on the current time.

Q

How to use the GotoIfTime application?

A

Syntax : GotoIfTime(times,weekdays,mdays,months,[timezone]?truelabel:falselabel)

Q

How to reload the Dialplan?

A

By using the following command on the asterisk CLI Dialplan reload

Q

Which file contains the dialplan context?

A

/etc/asterisk/extension.conf

Q

How to view the Sip extensions?

A

By using the following command on the asterisk CLI pjsip show endpoints

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Isaac ?
How to run windows application in linux

I need to run the windows application in my Linux machine, instead of installing from yum repo or any other repos. How to do that..??

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.