I am working on setting up the cron job using cv on a fresh CiviCRM and WordPress install. The docs are unclear on where to set up the "cronuser" user (WordPress user? CiviCRM contact?) and how to set the permissions needed for the cron to run successfully.
I think it depends on what cron solution you are using.
Since you say cv, I'll assume that you are running anacron or the like from the command line on Linux. I suggest that you run it as the user that owns the website. If you use Apache on Debian for example, the default web user is www-data.
In my case, for security reasons, I make the sites owned by a user I call www-dev and so I run the Civi cron jobs as that user.
You can access that user's crontab using sudo even if they aren't allowed to login like the www-data user:
sudo crontab -e -u www-dev.
You just need to be sure that whatever user you choose has write capabilities on the directory.
As for the WP user, if you're using the command line I don't think it matters as you never provide the password on the command line. I just use my own admin account. For example I use a crontab entry like this:
*/5 5-22 * * * /usr/local/bin/cv api job.execute --user=AdminUser --cwd=/var/www/wordpressroot > /dev/null
I suggest you set the
MAILTO= in the crontab file as well so you get an email if there is an error.
This helped me immensely -- thanks for the description and clear example!– MarkNov 15, 2022 at 13:59
The cronuser is a CMS user, so in your case a WordPress user. I tend to give the cron user a strong password and don't use that user account for anything but cron. As far as permissions, they need a good deal but it depends on the jobs running. CivICRM for WP now has the ability to create a CiviCRM administartor role (in the menu under settings
/wp-admin/admin.php?page=civi_options) - I'd start with that and remove unneded capabilities based on your cron/scheduled jobs.