Troubleshooting Guide

Crontab Permission Denied: How to Fix It

Getting "permission denied" when editing crontab or running cron jobs? Here's how to fix it.

Common Permission Denied Errors

There are several permission-related errors you might encounter:

/tmp/crontab.xxxxx: Permission denied
You (username) are not allowed to use this program (crontab)
/path/to/script.sh: Permission denied

Each has a different cause and fix. Let's go through them.

1. Script File Permissions

The most common issue: your script isn't executable.

# Check current permissions
ls -la /path/to/script.sh

# Make it executable
chmod +x /path/to/script.sh

Scripts need execute permission (x) to run directly. Without it, cron can't execute them.

2. User Not Allowed to Use Cron

If you see "not allowed to use this program", check /etc/cron.allow and /etc/cron.deny:

# Check if your user is blocked
cat /etc/cron.deny

# Or check if there's an allow list (if it exists, only listed users can use cron)
cat /etc/cron.allow

To fix:

  • Add your username to /etc/cron.allow, or
  • Remove your username from /etc/cron.deny

You'll need root access to modify these files:

sudo echo "yourusername" >> /etc/cron.allow

3. /tmp Directory Permissions

When you run crontab -e, it creates a temporary file in /tmp. If /tmp has wrong permissions:

# Check /tmp permissions
ls -la / | grep tmp

# Should show: drwxrwxrwt (sticky bit set)
# Fix if needed:
sudo chmod 1777 /tmp

4. Crontab Data File Ownership

Your personal crontab is stored in /var/spool/cron/crontabs/. If ownership is wrong:

# Check ownership (replace 'username' with your user)
ls -la /var/spool/cron/crontabs/

# Fix ownership if needed
sudo chown username:crontab /var/spool/cron/crontabs/username
sudo chmod 600 /var/spool/cron/crontabs/username

5. System Crontab Permissions

If you're adding jobs to /etc/cron.d/, files must be owned by root with specific permissions:

# Correct ownership and permissions
sudo chown root:root /etc/cron.d/myjob
sudo chmod 644 /etc/cron.d/myjob

Files with wrong ownership are silently ignored. You might see "WRONG FILE OWNER" in syslog.

6. Script Accessing Protected Resources

Your script might run but fail because it can't access certain files or directories:

# Check what user cron runs as
# User crontab runs as that user
# System crontab (/etc/crontab) can specify user

# Make sure the cron user can access needed files
ls -la /path/to/data/directory

# Fix if needed
chmod 755 /path/to/data/directory
# Or add user to appropriate group

Quick Checklist

  • Script has execute permission: chmod +x script.sh
  • User can use cron: not in /etc/cron.deny
  • /tmp has correct permissions: chmod 1777 /tmp
  • System cron files owned by root: chown root:root
  • Script can access all needed files/directories

Never debug silent cron failures again

CronSignal alerts you the moment a job doesn't run. Know about failures before they become disasters.

Start Monitoring Free

3 checks free. No credit card required.