Cron Oddity

Our webserver is running FreeBSD, for the last few days we have been having an issue with our cronjobs/mysql server.

Specifically we have jobs that execute php scripts to do various things to the website. When running these php scripts manually, via external browser, or lynx on the server, they run as expected, no issues. When running via cron, they experience connectivity issues to the mysql server. Users get denied to tables, or the connection doesn't get created. As you can imagine this has caused all kinds of havoc.

The question is, has anyone experienced this type of error before?

Why is it only on Cron that this happens?

Any way to fix this?

Any help you can give is most appreciated.

You can help yourself searching in the forum's base on how to troubleshoot cron jobs that aren't working, but here are my two cents : redirect the output of the command in a file and see what happens. Also, I've fixed such issues in FreeBSD 5.4 by restarting the cron service.

Tried to restart Cron, that didn't seem to solve the problem. I did try a search through the forum before posting, but didn't find anything specific to my issue. This is the error message I receive when trying to connect to mysql,

Could Not connect to Database on host:
localhost
Can't connect to local MySQL server through socket '/tmp/mysql.sock'

The server is running, and I am able to connect to it via mysql command line, the website, and phpmyadmin. It only fails when cron tries to access it

check /etc/my.cnf for following:

[mysqld]
.
.
.
bind-address = 127.0.0.1
port=3306

It is missing, both,

bind-address = 127.0.0.1
port=3306

Should they be added in?

This make mysql listen on this port at this address.

Depending on how your script connects this may be needed.

Thank you for the suggestion. Unfortunately that didn't solve the issue.

What's the exact error message you get ? If you're not sure where to look, cron will send a mail with any output generated by the script to the user.

Looks like the error was due to a corrupt privileges table. After resorting the table everything seems to work now. It's just odd that it wouldn't work on cron.

Thanks to everyone for the suggestions.