Using Cron Jobs in cPanel (Firstserv Guide)

Cron is a built-in Linux task scheduler that allows you to automate tasks on your server. It’s highly flexible and can run scripts, commands, or processes at set intervals.

Firstserv provides an easy way to manage cron jobs via cPanel, without needing to work directly with system files.


Accessing Cron Jobs

  1. Log in to cPanel
  2. Navigate to:
    Advanced → Cron Jobs
    

Cron Email Notifications

By default, cron output is sent to your account’s main email address.


Change Notification Email

  1. In the Cron Jobs page, locate the email section at the top
  2. Enter your preferred email address
  3. Click Update Email

✅ Useful for monitoring job output or errors


Adding a Cron Job


Step 1: Set the Schedule

You can choose:

  • ✅ Common Settings (e.g. once per day, every 5 minutes)
  • ✅ Or set custom values for:
    • Minute
    • Hour
    • Day
    • Month
    • Weekday

Step 2: Add the Command

Cron jobs run commands in the format:

<executable> <options> <script path>

Example: Running a PHP Script

 
 
 
 
 
 
Shell
 
 
/usr/bin/php -q /home/username/public_html/script.php
 
 

Breakdown:

  • /usr/bin/php → PHP executable
  • -q → Quiet mode (suppresses output)
  • /home/username/... → Full path to your script

Step 3: Save

  • Click Add New Cron Job

✅ Your task will now run automatically based on your schedule


Managing Existing Cron Jobs


Edit a Cron Job

  • Scroll to Current Cron Jobs
  • Click Edit
  • Update schedule or command
  • Click Edit Line to save

Delete a Cron Job

  • Click Delete next to the job
  • Confirm deletion

✅ This stops the task from running


Common Examples


Trigger WordPress Cron (wp-cron.php)

 
 
 
 
 
 
Shell
 
 
/usr/bin/wget -O /dev/null https://yourdomain.com/wp-cron.php?doing_wp_cron
 
 

Explanation:

  • wget fetches the URL
  • -O /dev/null discards output

Run a Script Directly

 
 
 
 
 
 
Shell
 
 
/home/username/script.sh > /dev/null 2>&1
 
 

Requirements for Executable Scripts

Your script must:

  • ✅ Include a valid shebang at the top:
 
 
 
 
 
 
Shell
 
 
#!/bin/bash
#!/usr/bin/python
#!/usr/local/bin/php
 
 
  • ✅ Have correct permissions:
 
 
 
 
 
 
Shell
 
 
chmod 755 script.sh
 

Understanding Output Redirection

 
 
 
 
 
 
Shell
 
 
> /dev/null 2>&1
 

This tells the system:

  • > → Redirect output
  • /dev/null → Discard output (“black hole”)
  • 2>&1 → Send errors to the same place

✅ Prevents emails being sent for every cron execution


Best Practices

  • ✅ Always use full file paths
  • ✅ Test your command manually before scheduling
  • ✅ Use output redirection to avoid unnecessary emails
  • ✅ Keep schedules reasonable (avoid overloading resources)

Using Cron Without cPanel

If you're using a VPS or dedicated server without cPanel:

  • Cron jobs can be configured manually using:
    crontab -e
    
  • Consult your system administrator if needed

Summary

  • Cron jobs automate tasks on your hosting account
  • Configure them easily via cPanel → Cron Jobs
  • Set schedules and commands to run scripts automatically
  • Use output redirection to keep logs clean
  • Edit or remove jobs at any time

Need Help?

If you need assistance setting up or troubleshooting cron jobs, the Firstserv support team is always happy to help.

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Managing Disk Usage in cPanel

Managing Disk Usage in cPanel (Firstserv Guide) Running low on storage can be stressful—but...

Get a free Let's Encrypt SSL for your website

An SSL (Secure Sockets Layer) certificate ensures that the connection between your website...

Importing Large MySQL Databases

Importing Large MySQL Databases (Firstserv Guide) If your database is too large to...

What happens if I exceed my disk space allowance?

Disk Space & Mailbox Usage (Firstserv Guide) Managing your disk space is essential to...

Backing Up Databases via SSH

Backing Up Databases via SSH (Firstserv Guide) This guide explains how to create MySQL...