Cron job times and tasks

I run a fairly large server and yes I hear your messages already that I should be running Enterprise.

Cron jobs seem to take a very long time. I have set the interval between them to 1 hour as they kept overlapping and they still seem to which makes my server run high CPU and causes issues.

What I want to see if the jobs that cron is running and how long they are taking so I can maybe streamline things.

Also, is it normal for a cron job to start another process if cron.php is already being run?

You could use flock instead of directly calling the php script.
See man flock for details.

I don’t think that this is a good idea… There are different types of jobs that will be run at different time intervals. So you’re also postponing the small jobs to only once an hour.

You can also set a maintenance window in your config.php to run the daily jobs only at a specific time:

https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/background_jobs_configuration.html#parameters

You can also get a list of all scheduled jobs with ./occ background-job:list:

./occ background-job:list --help
Description:
  List background jobs

Usage:
  background-job:list [options]

Options:
  -c, --class[=CLASS]    Job class to search for
  -l, --limit[=LIMIT]    Number of jobs to retrieve [default: "500"]
  -o, --offset[=OFFSET]  Offset for retrieving jobs [default: "0"]
      --output[=OUTPUT]  Output format (plain, json or json_pretty, default is plain) [default: "plain"]
  -h, --help             Display help for the given command. When no command is given display help for the list command
  -q, --quiet            Do not output any message
  -V, --version          Display this application version
      --ansi|--no-ansi   Force (or disable --no-ansi) ANSI output
  -n, --no-interaction   Do not ask any interactive question
      --no-warnings      Skip global warnings, show command output only
  -v|vv|vvv, --verbose   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
2 Likes

Hi @Justin_Zobel

You were asked if this was a support request when you started this thread and you answered “no”, which avoided filling out the support template, which propably could have make it possible to answer your question in any way satisfactorily without dragging every detail out of you.

I have several suspicions about why your cron jobs are taking so long, but I won’t voice them since you didn’t bother to provide accurate contextual information.

So please, show the community your respect and complete your support request with the necessary information. This is because other users with the same question from this thread should also be able to be helped later. This is only possible if the contextual details are included.


Much and good luck,
ernolf

3 Likes

Thank you @mwildam and @Chartman123 for your suggestions. I will try these shortly.

@ernolf your passive-aggressive reply isn’t welcome. However, if you think there is a specific piece or pieces of information you think would help in determining why the cron jobs are taking a long time, I would be happy to provide it. I am not sure how you came to the conclusion that I am being disrespectful by asking general questions.

Try changing the cron interval to the recommended and default 5 minutes.

I remember reading others having issues like this with too long intervals.

The problem with that is I end up with 3 or more cron jobs running at a time. That uses 3 times the CPU and ends up jamming up my system.