Search code examples
ejabberdmultiuserchat

Schedule a task to run daily on eJabberd server?


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?


Solution

  • 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 room
    • destroy_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.