Tengo varias consultas que deben ejecutarse cada noche. Pensé que podría hacer lo siguiente:
cd /var/discourse
./launcher enter app
su postgres
crontab -e
... agregar mis tareas y guardar ...
pero obtengo un error:
postgres@EN-Discourse-Forums-app:~$ crontab -e
crontab: instalando nueva crontab
crontab: crontabs/postgres: rename: Operación no permitida
crontab: ediciones dejadas en /tmp/crontab.7kGYwA/crontab
¿Es esto posible?
Falco
(Falco)
4 Octubre, 2019 19:11
2
The more “Discourse-way” of doing that would be creating a plugin with the queries as scheduled jobs.
Check this example:
# frozen_string_literal: true
module ::Jobs
class PatreonSyncPatronsToGroups < ::Jobs::Scheduled
every 6.hours
sidekiq_options retry: false
def execute(args)
unless SiteSetting.patreon_enabled && SiteSetting.patreon_creator_access_token &&
SiteSetting.patreon_creator_refresh_token
return
end
::Patreon::Patron.update!
::Patreon.set("last_sync", at: Time.now)
end
end
end
Inside the execute block you can do anything, like this job who runs SQL:
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.
Falco
(Falco)
4 Octubre, 2019 19:18
4