Ho diverse query che devono essere eseguite ogni notte. Pensavo di poter fare quanto segue:
cd /var/discourse
./launcher enter app
su postgres
crontab -e
... aggiungi i miei task e salva ...
ma ottengo un errore:
postgres@EN-Discourse-Forums-app:~$ crontab -e
crontab: installando nuovo crontab
crontab: crontabs/postgres: rename: Operazione non permessa
crontab: modifiche lasciate in /tmp/crontab.7kGYwA/crontab
È possibile farlo?
Falco
(Falco)
4 Ottobre 2019, 7:11pm
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:
3 Mi Piace
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 Ottobre 2019, 7:18pm
4
5 Mi Piace
system
(system)
Chiuso
5 Luglio 2023, 12:32pm
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.