Manually start asterisk using asterisk user

Generally we configure asterisk to auto run on system start up. There may be situations when we may be required to run asterisk manually like when asterisk is overloaded or when asterisk is down for some maintenance.

If so happens, always start asterisk from asterisk user:-


#su asterisk
#asterisk

We should not use any custom user and of course not “root” user. If we start asterisk as any non-asterisk user, various functionalities may be affected like our custom applications may not get permissions to execute asteisk cli commands.

For ex. If we run asterisk as root, then php apps running via apache, when execute asterisk cli commands, get following error:-
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

Run this command
#ls -l /var/run/asterisk/asterisk.ctl
srwxr-xr-x 1 root root 0 Aug 3 04:55 /var/run/asterisk/asterisk.ctl

As shown in the above result, non root users have no write permission.

Hence stop the asterisk using following command:-
#asterisk -rx "stop gracefully"
When asterisk will stop, use above mentioned process of starting asterisk as asterisk user.