does anybody know is it possible (drupal 6) to create several tasks which should run by crontab? I've created hook mymodule_cron but I need one more. Is it possible to create something like mymodule_another_task_cron?
Thanks
Why don't you add another task in your existing hook_cron? You can call whatever functions you want from one hook_cron.
I can highly recommend the Elysia Cron module
Elysia Cron extends Drupal standard cron, allowing a fine grain control over each task and several ways to add custom cron jobs to your site.
As a module developer the method you'll be most interested in is implementing hook_cronapi() to register jobs that can be scheduled individually through the Elysia cron admin settings.
There's also Ultimate Cron, but I can't vouch for that one as I've never used it.
Related
I have 2 .net core web projects.
One of them is called ScheduledJobs and it uses Hangfire with the dashboard to both schedule and process jobs.
The other is called ClientWebsite and it schedules the jobs only - but I dont want them executing here!
ScheduledJobs works fine, if I schedule anything from there it picks them up and processes them.
But since I need to be able to schedule jobs from clientWebsite too, I have to have the following settings in startup:
services.AddHangfire(x => x.UseSqlServerStorage(Configuration.GetConnectionString("DefaultConnection"));
services.AddHangfireServer();
If I dont call services.AddHangfireServer it wont even let me schedule them.
But if I add it, then it processes them too which I dont want !
Please help! Thanks
You shouldn't need to register the hangfire service at all in the second project in this way.
If you want to purely queue jobs from it you can use the GlobalConfiguration to set up which database it should point at similar to
GlobalConfiguration.Configuration.UseSqlServerStorage(Configuration.GetConnectionString("DefaultConnection"));
Once you have done this you can register a BackgroundJobClient similar to this (this is taken from an autofac example so depending on your DI it wont be exactly the same as the line below)
builder.RegisterType<BackgroundJobClient>().As<IBackgroundJobClient>();
What this then allows you to do is resolve and enqueue jobs using the IBackgroundJobClient in your application without setting up a hangfire server at all.
In your classes where you want to enqueue jobs from you can then simple resolve an instance of IBackgroundJobClient and make use of the Enqueue method such as
_myClient.Enqueue<MyJobClass>(x => x.APublicMethodOnMyJobClass());
Details on the backgroundjobclient can be found here - BackgroundJobClient
We want to avoid users to manually editing or adding new variables/connections from Airflow GUI in Production. Currently, we are using JSON files which loads all the connections and variables for Airflow.
Can experts guide me on how to achieve this?
Sergiy's right, you will need to start looking at Airflow's Role Based Access (RBAC) documentation and implement from there. Here's a place to start: https://airflow.readthedocs.io/en/latest/howto/add-new-role.html
As I always need to login to execute the tests and every time I need to re-do the log-in steps making it hard to maintain
I found out that on testcafe.js is possible to use hooks as a workaround but that is not the kind of optimal way
I need to save a constant login/password and alter them one time only as needed, just like a code but on the testcafe studio
We are planning to release a new version of TestCafe Studio this or next month. This version will contain the hooks feature, which would be built over TestCafe hooks (https://devexpress.github.io/testcafe/documentation/test-api/test-code-structure.html#initialization-and-clean-up)
Thus, you'll be able to use your login steps only once in hook without copying.
In addition, a bit later, we are planning to release the support of custom nodejs code inside a test, which will allow using the Roles mechanism.
What I need is execute one php file every hour. I found a lot of weird and not-understandable things about creating a module for Drupal (I don't need a whole module, I need to execute just ONE file).
Because my brain can't handle this dull realisation of Drupal or Cron.
Better solution is to use system crontab because it reduces load to php and your site will run faster.
Read more:
https://en.wikipedia.org/wiki/Cron
http://www.computerhope.com/unix/ucrontab.htm.
If you can't use system cron try to configure Drupal's cron: https://www.drupal.org/cron.
In worse case you can try https://www.drupal.org/project/poormanscron module.
If you want to do it the Drupal-y way, instead of a more hacky way outside of what Drupal is meant to do, use hook_cron().
To do this, you will need to create a new module with that function inside of module_name.module. You can view the documentation on creating a new module in Drupal six here. You should only need the "Getting Started" and "Tell Drupal about your module" sections.
In your module_name.module file, write a hook_cron() function. The hook will be replaced by the machine-name of your module.
The description of hook_cron() on Drupal.org is as follows:
Modules that require to schedule some commands to be executed at regular intervals can implement hook_cron(). The engine will then call the hook at the appropriate intervals defined by the administrator. This interface is particularly handy to implement timers or to automate certain tasks. Database maintenance, recalculation of settings or parameters, and automatic mailings are good candidates for cron tasks.
Without more details of what you are trying to accomplish or more details about your script, this is all I can provide.
I have a little question, how create a simple cron task who call some service action in Symfony, who could be executed automatically each night ?
Symfony2 does not manage cron tasks, simply because this is system level. That being said, you can create a command and register it as a cron task.
You can use CommandSchedulerBundle
You can now use TaskScheduleBundle to make your cron jobs within symfony.