Mautic Community Forums

Should I use -f in cron jobs?

I have logging on my cron tasks



When I’m having genuine issues with Mautic I often run in to this entry in the logs:



Script in progress. Use -f or --force to force execution.



However, sometimes like today, everything “seems” to be working fine with Mautic but I still see new entries of this line in the CampaignUpdate Log.



I can clear it if I run the command with -f



I noticed recently in this GitHub post that this user has his cron task set to -f all the time ( https://github.com/mautic/mautic/issues/1338 )



Is this bad practice or should I be doing this?



Is the “Script in progress. Use -f or --force to force execution.” expected from time to time? Will it clear on its own?


I have logging on my cron tasks

When I’m having genuine issues with Mautic I often run in to this entry in the logs:

Script in progress. Use -f or --force to force execution.

However, sometimes like today, everything “seems” to be working fine with Mautic but I still see new entries of this line in the CampaignUpdate Log.

I can clear it if I run the command with -f

I noticed recently in this GitHub post that this user has his cron task set to -f all the time ( https://github.com/mautic/mautic/issues/1338 )

Is this bad practice or should I be doing this?

Is the “Script in progress. Use -f or --force to force execution.” expected from time to time? Will it clear on its own?

Good question. The background (cron) jobs can take a while to process all of the data. Imagine you have 1.000.000 leads with email and you create a list with filter “has email”. It has to create a million relations. Then some other background job is started and interferes with the one currently running. It could cause some troubles. That’s why the background job creates a flag file while they run and if that file exist, no other background job starts. Unless you force it to (–force).

One problem I’ve seen with this approach is, that if there is a PHP error in the background job execution, the job will never remove the flag file and no other background job will start unless you force it to.

So the answer is, do not use the --force in the cron tab. It could cause unpredictable troubles. Use it if you are sure there was some error and you want to start the jobs again.

This is not a good solution, but it’s all we have right now. Suggestions or even pull requests with better implementation are welcome.

Thanks

Oh, I had this issue:
Script in progress. Use -f or --force to force execution.
so just now set my crons to --force.
But now I have read this thread.
Should I now take off the --force?
But what if the issue turns up again?
Do I have to keep logging into my cpanel and adding --force to the end of the cron commands?
My timings are set to */2 for all crons, could this have caused the issue?
Maybe I should stagger them?
any advice would be welcome, as I just cant get on with building my campaigns due to this unreliablity of the crons.
Thanks guys

The idea is that you should not need to use the --force, but there are still some issues on different server settings with different Mautic configuration. So what I would do is to keep the normal cron which runs every few minutes without the --force and set up another one which would run once or twice a day with the --force so if something would go wrong, this will fix it.

Thanks escopecz,

At the moment I am in testing stage, so only my one test lead/contact being used.
If I set --force to run once per day it would take forever for me to get everything tested.
So would it be ok to leave the --force on until testing is completed and my projects are built (may be a few weeks/months)?

then when all is set up, do as you suggest. Set the crons to run every 30 mins, staggered, then also have the --force versions to run once per day just incase?

I am on a shared host, so not sure if that is an issue but I would have thought shared hosts should be prepared for people to use crons at frequent intervals.