XF 2.1 How do I add Rebuild user caches as a cron job?

PatPeter

Member
Hi everyone,

I'm trying to mirror a personally-managed database called roster with the user groups in XenForo. Here's an example of my query:

UPDATE xenforo.xf_user xu
LEFT OUTER JOIN roster.member rs
ON (xu.user_id = rs.forums_id)
SET user_group_id = 13, secondary_group_ids = "2,14,15"
WHERE rs.rank_id = 4;


I ran this query, and I'm seeing the values correctly populated in the database. However, none of my users have their Title set to the title of their new user group.

How do I refresh XenForo so that it properly displays ranks changed in the database and not on the backend? I need to have this done by Friday so any and all help is appreciated.
 

PatPeter

Member
Alright, I found the job that allows me to update user ranks:

/admin.php?tools/run-job&only_id=1759&_xfRedirect=%2Fadmin.php%3Ftools%2Frebuild%26success%3D1

However, if you'll indulge me to change the purpose of this thread, is it possible to run this as a cronjob on my server?
 

PatPeter

Member
Almost a year late, but thank you so much @duderuud ! I installed this on my server and it was exactly what I was looking for. I can do this now:

Code:
0 6 * * * /usr/bin/php $HOME/public_html/cmd.php -- xf-rebuild:users | tee /tmp/xf_rebuild_users.log

I am running into an issue with this cron job though, the output file says:

Code:
Content-type: text/html; charset=UTF-8

This script can only be run via the command line interface.

I'm looking into how to fix it.

Fixed: https://xenforo.com/community/threads/cli-job-runner-for-xf-2-1.148636/post-1524576
 
Last edited:
Top