Requirements crontab configuration 040Hosting.
As per our TOS we do not allow 1 minute cronjobs, and 5 or 10 minute cronjobs can be requested through support.
cronjobs set to 5 or 10 minutes without approval can be removed or rescheduled to 15 minutes.
When you have requested and are allowed to run a 5 or 10 minute cronjob we have the following requirement for such job:
- The cronjob MUST check if another instance of the same job is still running and act accordingly. Either by stopping the previous job or to skip the job for the current run.
This is to avoid cronjobs stacking and causing issues on the server by running many concurrent processes. We would call it just good housekeeping; even though the accounts have limited processes they can run it can cause lots of issues with your own and other users if such jobs are not being controlled properly.
an example of how you can create a lockfile to avoid a cron from running while another earlier version is still running is:
#!/bin/bash
# Set the lock file path
LOCKFILE=/tmp/mycronjob.lock
# Check if lock file exists
if [ -f "$LOCKFILE" ]; then
echo "Cron job is already running, exiting."
exit 1
fi
# Create lock file
touch "$LOCKFILE"
# Run your cron job here
echo "Running cron job..."
# Remove lock file
rm "$LOCKFILE"
For more information you can always contact our support team.