I want to set up a task that will destroy all inactive persistent chat rooms on my eJabberd server. Is it possible to set up such a task?
2 Answers
ejabberdctl
command-line tool can give you MUC administration commands access when the module mod_muc_admin
is enabled in ejabberd. That module is available as default since ejabberd 15.04.
Once enabled, you should have access to several commands to destroy MUC rooms:
destroy_room
to destroy a specific MUC roomdestroy_rooms_file
to destroy a list of MUC rooms.rooms_unused_destroy
to destroy all MUC rooms that have not been used in N days.
The list of commands is available in ejabberd documentation: Multi User Chat Administration Commands.
You will be probably using the command rooms_unused_destroy
, as it seems to do exactly what you need.
Regarding the scheduling of the task, you should rely on your Operating System scheduling tool, for example cron. You should be careful and test your command manually during several days before automating it, to avoid any mistake.

- 9,035
- 1
- 24
- 44
-
Thanks for the response. Do you know by any chance how to enable mod_muc_admin on Unbuntu? As soon as I add {mod_muc_admin, []}, to my Modules and restart my .cfg it breaks the server. I'm running ejabberd 2.1.11 on the server. – Lasonic Aug 05 '15 at 15:23
-
As mentioned: "That module is available as default since ejabberd 15.04.". You need to install ejabberd 15.04 and up. It will not work on ejabberd 2.1 so you need to install ejabberd yourself to use that module. – Mickaël Rémond Aug 05 '15 at 15:25
-
You cannot. You need to use newer ejabberd. – Mickaël Rémond Aug 05 '15 at 16:41
-
Well in that case, could you point me in the right direction on install eJabberd 15.04 on an Ubuntu server? – Lasonic Aug 05 '15 at 16:43
-
Documentation is here: http://docs.ejabberd.im/admin/guide/installation/ with all options: Binary installer, experimental deb package and compilation from source code. Download page is: http://www.process-one.net/en/ejabberd/downloads/ – Mickaël Rémond Aug 05 '15 at 16:58
You could create a cron job on the server if it is running linux to kill all the chat rooms. I don't know what the command would be for ejabbered, but a line for something like the below. If you wanted it to run once a day.
1 1 * * * service ejabberd restart
Minute
Hour
Days
Weeks
Months

- 1,838
- 2
- 21
- 48
-
My eJabberd sever is on an Ubuntu server. I'm very new to this, what exactly is a cron job? – Lasonic Aug 05 '15 at 01:24
-
It's a command that is ran at a certain time everyday. See `man crontab` for a quick intro. http://www.unixgeeks.org/security/newbie/unix/cron-1.html – HSchmale Aug 05 '15 at 01:26
-
If my command was "service ejabberd restart" how would that look like with all the spaces? – Lasonic Aug 05 '15 at 01:42
-
so I don't need to prefix it with root as seen in the link you send me? – Lasonic Aug 05 '15 at 04:54
-
ejabberd restart will not destroy persistent chat rooms. They are persistent and by definition kept across restart. – Mickaël Rémond Aug 05 '15 at 09:27
-
@Lasonic If you are restarting the process, you would want to put that command into root's crontab – HSchmale Aug 05 '15 at 16:28