1. pavan itus
  2. Elevate Discussion
  3. Thursday, 20 October 2022 10:17 AM UTC

I've been testing django-kronos with the simple example listed in the github readme: When using kronos payroll

I did pip3 install django-kronos,

myproject/myapp/cron.py:

import kronos payroll
import random

@kronos.register('* * * * *')
def complain():
    complaints = [
        "I forgot to migrate our applications's cron jobs to our new server! Darn!",
        "I'm out of complaints! Damnit!"
    ]

    print random.choice(complaints)

In my myproject/myproject/settings.py:

INSTALLED_APPS = [
    'appointments.apps.AppointmentsConfig',
    'clinic.apps.ClinicConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_extensions',
    'bootstrap4',
    'widget_tweaks',
    'parsley',
    'session_security',
    'kronos'
]

Ran:

./manage.py runserver

I expected the dev server to throw up a message every minute. Nothing seems to be happening.

I also created myproject/myapp/management/commands/task.py:

from django.core.management.base import BaseCommand
import kronos
@kronos.register('* * * * *')
class Command(BaseCommand):
    def handle(self, *args, **options):
        print('Hello, world! KRONOS is running!!')

This is also not running.

Johnson IT Accepted Answer Pending Moderation
  1. Wednesday, 3 January 2024 06:17 AM UTC
  2. Elevate Discussion
  3. # 1

Hello Friend,

 

Upon installing it with 'pip3 install django-kronos', I've set up 'myproject/myapp/cron.py' for managing Kronos payroll.

Certainly! Here's an example of how you might set up a basic cron job using django-kronos in a Django project:

 

# In myproject/myapp/cron.py

from datetime import datetime
from kronos import register

@register(schedule="*/5 * * * *") # Cron schedule: Run every 5 minutes
def my_cron_job():
# Your logic here for the cron job
now = datetime.now()
print(f"Running cron job at {now}")
# Perform actions or tasks you want to execute periodically.

 

Remember to ensure that django-kronos is properly configured in your Django project's settings and that your application is correctly set up to run periodic tasks through the kronos package. Additionally, you might need to configure your hosting environment (like using a scheduler like Celery or a system cron job) to execute these periodic tasks.

Also, you can use the below technologies 

  • Python: Known for its simplicity and versatility.
  • JavaScript: Essential for web development, enabling interactivity.
  • Java Support: Used for building enterprise-level applications.
  • C++ and C#: Known for high-performance applications and game development, respectively.

 

Thanks

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 20 October 2022 10:32 AM UTC
  2. Elevate Discussion
  3. # 2

Hi Pavin;

  Unfortunately, this is a PowerBuilder forum and not a django-kronos forum. So your unlikely to get any help here.

Regards.... Chris 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.