Answers.Body: <p>Not sure what you mean by &quot;php user&quot; - there is the web server user, and then there is a unix logged in user if you are logged into a shell, and then there is whatever user runs cron. Basically you want all those files and folders under templates_c to be writable by the web server user, and you want cron to run under the web server user, and if you ever run a command like <code>cv flush</code> or <code>cv api3 Job.execute</code> via cli, then you want to sudo first to the web server user.</p>
  <p>To get cron to run as the web server user, it depends on your OS and how your cron is configured, but generally you either specify it on the crontab line itself, or the command to run should use sudo in it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-20T22:09:34.960Z
Answers.LastActivityDate: 2024-09-20T22:09:34.960Z
Answers.UserDisplayName: Demerit
Body: <p>Have been trying to set up CiviCRM with Drupal 11 on AWS  Bitnami LAMP instance.
  Got a filesystem ownership clash, where webserver user (&quot;bitnami&quot;) can't access files and folders created by php user (&quot;daemon&quot;).
  As a result a cronjob is not  running.</p>
  <pre><code> cd /opt/bitnami/apache/htdocs/ &amp;&amp;  cv api job.execute  --user=superadmin
  </code></pre>
  <blockquote>
  <p>Cannot rename &quot;/opt/bitnami/apache/tmp/CachedCiviContainer.b47da0ea0743e6e1837ccabee79093b2.phpZJ2pp9&quot; to &quot;/opt/bitnami/<br />
  apache/htdocs/sites/default/files/civicrm/templates_c/CachedCiviContainer.b47da0ea0743e6e1837ccabee79093b2.php&quot;: rename(<br />
  /opt/bitnami/apache/tmp/CachedCiviContainer.b47da0ea0743e6e1837ccabee79093b2.phpZJ2pp9,/opt/bitnami/apache/htdocs/sites/<br />
  default/files/civicrm/templates_c/CachedCiviContainer.b47da0ea0743e6e1837ccabee79093b2.php): Permission denied</p>
  </blockquote>
  <p>In theory, adding the &quot;bitnami&quot; user to the &quot;daemon&quot; group (or further manipulations at php-fpm config files level) should resolve this, however, maybe, there is another, simpler way of resolving this?</p>
  
Tags: <drupal><cron><cron-job><bitnami>
Title: How do you run "cv api job.execute" if the "templates_c" folder is being owned by daemons?
ThreadText: # How do you run "cv api job.execute" if the "templates_c" folder is being owned by daemons?
  
  (Asked by: username_0 on 2024-09-20)
  
  Have been trying to set up CiviCRM with Drupal 11 on AWS Bitnami LAMP instance.
  Got a filesystem ownership clash, where webserver user ("bitnami") can't access files and folders created by php user ("daemon").
  As a result a cronjob is not running.
  
  ```
   cd /opt/bitnami/apache/htdocs/ &&  cv api job.execute  --user=superadmin
  
  ```
  
  > Cannot rename "/opt/bitnami/apache/tmp/CachedCiviContainer.b47da0ea0743e6e1837ccabee79093b2.phpZJ2pp9" to "/opt/bitnami/  
  > apache/htdocs/sites/default/files/civicrm/templates\_c/CachedCiviContainer.b47da0ea0743e6e1837ccabee79093b2.php": rename(  
  > /opt/bitnami/apache/tmp/CachedCiviContainer.b47da0ea0743e6e1837ccabee79093b2.phpZJ2pp9,/opt/bitnami/apache/htdocs/sites/  
  > default/files/civicrm/templates\_c/CachedCiviContainer.b47da0ea0743e6e1837ccabee79093b2.php): Permission denied
  
  In theory, adding the "bitnami" user to the "daemon" group (or further manipulations at php-fpm config files level) should resolve this, however, maybe, there is another, simpler way of resolving this?
  
  **Tags:** drupal, cron, cron-job, bitnami
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-09-20. Score: 2 | Accepted answer
  
  Not sure what you mean by "php user" - there is the web server user, and then there is a unix logged in user if you are logged into a shell, and then there is whatever user runs cron. Basically you want all those files and folders under templates\_c to be writable by the web server user, and you want cron to run under the web server user, and if you ever run a command like `cv flush` or `cv api3 Job.execute` via cli, then you want to sudo first to the web server user.
  
  To get cron to run as the web server user, it depends on your OS and how your cron is configured, but generally you either specify it on the crontab line itself, or the command to run should use sudo in it.
  
  
  ---
  
  