Knowledge Base

SSH Access and Cron Jobs in Enhance

SSH Access and Cron Jobs in Enhance

Ready to take the training wheels off? SSH access and cron jobs give you powerful control over your hosting environment.

Understanding SSH

SSH (Secure Shell) is a secure way to connect to your server's command line. It's like being able to sit at the server's keyboard - but from anywhere in the world.

Why Use SSH?

  • Run commands directly on the server
  • Use tools like Git, Composer, npm, and WP-CLI
  • Debug issues that can't be resolved via GUI
  • Automate tasks with scripts
  • Transfer files securely with SFTP/SCP

Enabling SSH Access

Setting Up SSH

  1. Navigate to Websites > Your Domain
  2. Click SSH Access or Shell Access
  3. Enable SSH for your account
  4. Set or generate a password

[SCREENSHOT: SSH access settings showing the enable toggle and password field]

Connection Details

Setting Value
Host Your domain or server IP
Port 22
Username Your SSH username
Password Your SSH password

Connecting via SSH

Mac/Linux Terminal

  1. Open Terminal
  2. Type: ssh username@yourdomain.com
  3. Enter your password when prompted
  4. You're in!
ssh myuser@example.com
myuser@example.com's password: ********
Welcome to your hosting environment!
$

Windows (PowerShell)

Windows 10/11 includes SSH:

  1. Open PowerShell
  2. Type: ssh username@yourdomain.com
  3. Enter your password

Windows (PuTTY)

For older Windows versions or more features:

  1. Download PuTTY from putty.org
  2. Open PuTTY
  3. Enter your host and port
  4. Click Open
  5. Enter username and password

[SCREENSHOT: PuTTY configuration window with host and port fields]

SSH Key Authentication

Typing passwords is so last decade. SSH keys are more secure and convenient.

Generating SSH Keys

On Mac/Linux:

ssh-keygen -t ed25519 -C "your@email.com"

On Windows (in PowerShell):

ssh-keygen -t ed25519 -C "your@email.com"

This creates two files:

  • ~/.ssh/id_ed25519 (private key - keep this secret!)
  • ~/.ssh/id_ed25519.pub (public key - this goes on the server)

Adding Your Key to Enhance

  1. Go to SSH Access settings
  2. Click SSH Keys or Authorized Keys
  3. Click Add Key
  4. Paste your public key (contents of .pub file)
  5. Save

[SCREENSHOT: SSH key management showing the add key form]

Connecting with Keys

Now you can connect without a password:

ssh username@yourdomain.com
# No password needed!

Common SSH Commands

Navigation

pwd                 # Print current directory
ls                  # List files
ls -la              # List all files with details
cd /path/to/dir     # Change directory
cd ..               # Go up one directory
cd ~                # Go to home directory

File Operations

cp file1 file2      # Copy file
mv file1 file2      # Move/rename file
rm file             # Delete file (careful!)
rm -r directory     # Delete directory (very careful!)
mkdir newfolder     # Create directory
cat filename        # Display file contents
nano filename       # Edit file (Ctrl+X to exit)

Useful Commands

df -h               # Check disk space
du -sh folder       # Check folder size
top                 # View running processes
tail -f logfile     # Watch log file in real-time
grep "error" file   # Search for text in file
find . -name "*.php" # Find files by name

Web Development Tools

# PHP
php -v              # Check PHP version
php script.php      # Run PHP script

# Composer
composer install    # Install dependencies
composer update     # Update dependencies

# Node.js/npm
node -v             # Check Node version
npm install         # Install packages
npm run build       # Run build script

# Git
git status          # Check repo status
git pull            # Pull latest changes
git log             # View commit history

# WordPress CLI
wp core version     # Check WordPress version
wp plugin list      # List plugins
wp cache flush      # Clear cache

[SCREENSHOT: Terminal showing various commands being executed]

Cron Jobs: Automating Tasks

Cron jobs run commands on a schedule - perfect for:

  • Database backups
  • Sending scheduled emails
  • Clearing caches
  • Running maintenance scripts
  • Fetching external data

Understanding Cron Syntax

Cron uses a five-field format:

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

Common Schedules

Schedule Cron Expression Meaning
Every minute * * * * * Runs constantly
Every hour 0 * * * * At minute 0 of every hour
Every day at midnight 0 0 * * * Daily at 00:00
Every Monday at 9 AM 0 9 * * 1 Mondays at 09:00
Every 15 minutes */15 * * * * 0, 15, 30, 45 past each hour
Twice a day 0 8,20 * * * 8 AM and 8 PM
First of month 0 0 1 * * Midnight on the 1st

Creating Cron Jobs in Enhance

  1. Navigate to Websites > Your Domain > Cron Jobs
  2. Click + Add Cron Job
  3. Set the schedule using:
    • Dropdown menus (easy mode)
    • Or manual cron syntax (advanced)
  4. Enter the command to run
  5. Save the cron job

[SCREENSHOT: Cron job creation form with schedule options and command field]

Example Cron Jobs

WordPress Cron

# Run WordPress scheduled tasks every 15 minutes
*/15 * * * * cd /home/user/public_html && wp cron event run --due-now

Database Backup

# Daily database backup at 3 AM
0 3 * * * mysqldump -u dbuser -p'password' dbname > /home/user/backups/db_$(date +\%Y\%m\%d).sql

Clear Cache

# Clear cache every hour
0 * * * * rm -rf /home/user/public_html/wp-content/cache/*

Run PHP Script

# Run a maintenance script daily at midnight
0 0 * * * /usr/bin/php /home/user/public_html/maintenance.php

Cron Job Tips

  1. Use full paths - Cron doesn't use your regular environment
  2. Redirect output - Add >> /path/to/logfile.log 2>&1 to capture output
  3. Test manually first - Run your command via SSH before scheduling
  4. Check for overlap - If a job takes 10 minutes, don't run it every 5 minutes
  5. Monitor logs - Check that jobs are actually running successfully

Disabling WordPress Built-in Cron

WordPress has its own pseudo-cron that runs on page visits. For better reliability, use real cron:

  1. Add to wp-config.php:

    define('DISABLE_WP_CRON', true);
  2. Create a cron job:
    */15 * * * * curl -s https://yourdomain.com/wp-cron.php > /dev/null 2>&1

Per-Website Isolation

Enhance runs cron jobs and SSH sessions in isolated containers per website. This means:

  • Your cron can't affect other websites
  • Resource limits are enforced
  • Security is maintained
  • If one site has issues, others aren't affected

Troubleshooting

"Permission Denied"

  • Check file permissions: chmod +x script.sh
  • Verify you're using the correct user
  • Check if the directory is accessible

"Command Not Found"

  • Use full paths: /usr/bin/php instead of just php
  • Check if the command is installed
  • Verify your PATH environment variable

Cron Jobs Not Running

  1. Check cron syntax is correct
  2. Verify the command works when run manually
  3. Check for any output/errors in logs
  4. Ensure the cron service is enabled for your account
  5. Check time zone settings

SSH Connection Refused

  • Verify SSH is enabled for your account
  • Check you're using the correct port (usually 22)
  • Verify your IP isn't blocked
  • Contact us if issues persist

Need more help? Browse our other Knowledge Base articles or contact our support team!

Please rate this article to help us improve our Knowledge Base.

0 0