Skip to Content
🇬🇧Cron Jobs

Cron Jobs

Schedule automated tasks for your web applications. Regular script execution, cache cleanup, e-mail sending, and more.


Overview

FeatureDetails
SyntaxStandard cron format
Minute PrecisionEvery minute to once per year
LoggingOutput to log
E-mailNotification on error
Enable/DisableYes

Cron Format

Basic Syntax

* * * * * command │ │ │ │ │ │ │ │ │ └── Day of week (0-7, 0 and 7 = Sunday) │ │ │ └──── Month (1-12) │ │ └────── Day of month (1-31) │ └──────── Hour (0-23) └─────────── Minute (0-59)

Examples

CronMeaning
* * * * *Every minute
0 * * * *Every hour
0 0 * * *Every day at midnight
0 2 * * *Every day at 2:00 AM
0 0 * * 0Every Sunday at midnight
0 0 1 * *First day of every month
*/15 * * * *Every 15 minutes
0 9-17 * * *Every hour 9 AM-5 PM

Creating Cron Job

Step 1 — Open Cron Section

  1. Log in to CoreSynth Dashboard 
  2. Go to Web Hosting
  3. Select your hosting package
  4. Click Cron in sidebar

Step 2 — New Job

  1. Click Create Job
  2. Fill in:
FieldDescription
Minute0-59 or *
Hour0-23 or *
Day of Month1-31 or *
Month1-12 or *
Day of Week0-7 or *
CommandPath to script
  1. Click Create

Command Examples

# PHP script /usr/bin/php /home/user/domains/example.com/public_html/cron.php # PHP script with parameters /usr/bin/php /home/user/domains/example.com/public_html/cron.php --task=cleanup # Wget for HTTP call /usr/bin/wget -q -O /dev/null https://example.com/cron.php # Curl for HTTP call /usr/bin/curl -s https://example.com/cron.php > /dev/null # Script in home directory /home/user/scripts/backup.sh

Tip: Use absolute paths for reliability.


Managing Jobs

Enable/Disable Job

  1. In job list click Enable or Disable
  2. Disabled job won’t run but stays in list

Editing Job

  1. In job list click Edit
  2. Change time or command
  3. Click Save

Deleting Job

  1. In job list click Delete
  2. Confirm deletion

Common Use Cases

WordPress Cron

# WordPress scheduled tasks */5 * * * * /usr/bin/php /home/user/domains/example.com/public_html/wp-cron.php

Recommendation: Set define('DISABLE_WP_CRON', true); in wp-config.php.

Laravel Scheduler

# Laravel scheduler * * * * * /usr/bin/php /home/user/domains/example.com/public_html/artisan schedule:run >> /dev/null 2>&1

Cache Cleanup

# Clear Laravel cache daily 0 3 * * * /usr/bin/php /home/user/domains/example.com/public_html/artisan cache:clear

Database Backups

# MySQL backup daily 0 2 * * * /usr/bin/mysqldump -u user -p'password' database > /home/user/backups/db_$(date +\%Y\%m\%d).sql

Sending E-mails

# Send newsletter weekly 0 9 * * 1 /usr/bin/php /home/user/domains/example.com/public_html/send-newsletter.php

Logging

Output to Log

# Output to log file * * * * * /usr/bin/php /home/user/script.php >> /home/user/logs/cron.log 2>&1

Log Only Errors

# Log only errors * * * * * /usr/bin/php /home/user/script.php > /dev/null 2>> /home/user/logs/cron-error.log

Suppress Output

# Suppress all output * * * * * /usr/bin/php /home/user/script.php > /dev/null 2>&1

Troubleshooting

Job Not Running

Cause: Wrong time or disabled.

Solution:

  1. Check if job is enabled
  2. Check timing (minute, hour, etc.)
  3. Check output log

”Command Not Found” Error

Cause: Wrong command path.

Solution:

  1. Use absolute path: /usr/bin/php instead of php
  2. Find path: which php
  3. Use found path

”Permission Denied” Error

Cause: Script lacks execute permission.

Solution:

  1. Set permission: chmod +x script.sh
  2. For PHP scripts use php /path/to/script.php
  3. Check file owner

Script Works Manually Not in Cron

Cause: Different environment.

Solution:

  1. Set PATH in crontab:
    PATH=/usr/local/bin:/usr/bin:/bin
  2. Use absolute paths
  3. Set working directory:
    cd /home/user/domains/example.com/public_html && /usr/bin/php script.php

Security Recommendations

  • Use absolute paths
  • Log errors to files
  • Set reasonable intervals (not every minute)
  • Lock sensitive scripts
  • Use .htaccess for HTTP crons:
    <Files "cron.php"> Order Allow,Deny Allow from localhost Deny from all </Files>

Next Steps


Need help? Open a support ticket  or ask Alex in your dashboard.

Last updated on