Continuous Crontab emails – ambiguous redirect – Cpanel / WHM

If you own a dedicated server or VPS there maybe times where you or someone who manages your server has edited the crontab incorrectly causing a flood of “ambiguous redirect” emails, this is normally caused by the crontab being edited outside of linux which has caused corrupted line endings. Emails will be similar to the following :

/bin/sh: 1
: ambiguous redirect

/bin/sh: /usr/local/bandmin/bandmin
: No such file or directory

/bin/sh: /usr/local/cpanel/bin/tail-check
: No such file or directory

With subject lines similar to these but can be slightly different depending on your crontab entries.

Cron /usr/bin/test -x /usr/local/cpanel/bin/tail-check && /usr/local/cpanel/bin/tail-check

Cron /usr/local/cpanel/whostmgr/bin/dnsqueue > /dev/null 2>&1

Lets See if its broken

Run the following command :

# file /var/spool/cron/root

If you get something like this : /var/spool/cron/root: ASCII text it means all is correct, if however it mentions line terminators it means there is an issue and confirms what we’ve said above, it indicates the file has been edited outside of the correct environment ( often caused when someone has logged in as root via sFTP and manually edited the file with a html editor such as dreamweaver or similar on their PC and then reuploaded it causing the corruption.

How to fix / resolve the problem

Login to your server via SSH with your favorite terminal such as PUTTY and do the following command. Please note: This command only works on some machines, if you get a “not found” error then move onto the second command :

# dos2unix -b /var/spool/cron/root

Or Alternatively:

# strings /var/spool/cron/root > /var/spool/cron/root.tmp
# mv /var/spool/cron/root.tmp /var/spool/cron/root

If you are still having issues feel free to get in touch and ask about our services.