kimai / kimai

Kimai is a web-based multi-user time-tracking application. Works great for everyone: freelancers, companies, organizations - everyone can track their times, generate reports, create invoices and do so much more. SaaS version available at https://www.kimai.cloud
https://www.kimai.org
GNU Affero General Public License v3.0
3.1k stars 543 forks source link

Central entry point for cronjobs #141

Open simonschaufi opened 6 years ago

simonschaufi commented 6 years ago

Description

In order to send automated emails, I need an entry point for my cronjob (like a global scheduler) where I can register my cronjob task to be executed.

Laravel has it here: https://laravel.com/docs/8.x/scheduling. Maybe there is also something available for symfony?

The alternative would be to make CommandControllers for every single cronjob (which works already).

adrianrudnik commented 4 years ago

Not sure what the benefit of that artisan scheduling is. Is it a way around crontab? You still need to register the artisan command, so you could do it better documented in cron.d file anyway? You could even keep it under source control and just symlink your cron directives.

What cronjobs do you want to schedule, commands offered by kimai through the symfony console?

kevinpapst commented 4 years ago

I am currently investigating some possible solutions. This is my favorite library so far (just from reading, not tested yet): https://github.com/Cron/Cron The idea is not that bad, the admin has to create only one cron job for Kimai and can then forget about it. Every plugin developer could simply register their own cron job, without the need to edit crontab again.

On the other hand it is a lot of code overhead for a task, which is perfectly stable from OS side.

adrianrudnik commented 4 years ago

Yeah, that seems like a alot of overhead in comparison to a cron.d file.

This app could just deliver a template like

# /etc/cron.d/kimai
www-data * * * * * cd app && bin/console kimai:do1
www-data */5 * * * cd app && bin/console  kimai:do2
www-data @daily cd app && bin/console kimai:daily

that could be symlinked, copied, easily modified, changed and so on. As long as you need to add a crontab/cron.d job anyway, there is no benefit in having your app trying to be the os responsible for these tasks.

On the other hand you could provide a simple controller action that could be triggerable on the public url, for the really worse cases where php-cli has highly different settings/version/user than php-fpm (leading to unwritable cache dirs and so on) or you do not have shell access or your hoster only allows you to pull an url. And for that you could inject the commands directly into the controller and call them without any additional dependency.

kevinpapst commented 4 years ago

https://github.com/zenstruck/schedule-bundle

simonschaufi commented 4 years ago

This is exactly what I was looking for!

limitedAtonement commented 3 years ago

Sounds like this one can be closed?

simonschaufi commented 3 years ago

No, it's not yet implemented

adrianrudnik commented 3 years ago

@simonschaufi the bundle mentioned by @kevinpapst was no help?

simonschaufi commented 3 years ago

I'm not talking about a support request but about a core feature of kimai which makes it much easier for plugin developers to add cronjobs without adjusting any crontab config.