Puis-je exécuter un cron job en tant que l'utilisateur Postgres ?

J’ai plusieurs requêtes à exécuter chaque nuit. J’ai pensé pouvoir faire ce qui suit :

cd /var/discourse
./launcher enter app
su postgres
crontab -e
... ajoutez vos tâches et enregistrez ...

Mais j’obtiens une erreur :

postgres@EN-Discourse-Forums-app:~$ crontab -e
crontab: installation du nouveau crontab
crontab: crontabs/postgres: renommage : Opération non autorisée
crontab: modifications laissées dans /tmp/crontab.7kGYwA/crontab

Est-ce possible ?

The more “Discourse-way” of doing that would be creating a plugin with the queries as scheduled jobs.

Check this example:

Inside the execute block you can do anything, like this job who runs SQL:

3 « J'aime »

Potentially, yes, but this doesn’t let others who may need to change the behavior of these queries and our servers use something they understand. It is very common to use CRON to run queries.

Did you read How to add a job to cron/anacron when creating Docker container ?

5 « J'aime »

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.