I have a PHP cli script, that backups my databases, using mysqldump
via system().
When logged in with SSH, and launching the script with "./backup.php",
all works just as it should, but when I put it in a crontab:
00 2 * * * /home/sandman/bin/backup.php
I get a mail that says:
"mysqldump: Got error: 2002: Can't connect to local MySQL server
through socket '/var/run/mysqld/mysqld.sock' (2) when trying to
connect"
How come? Anyone knows what the difference is between CLI and crontab
that could cause this?
--
Sandman[.net] 3 3370
Sandman wrote:
I have a PHP cli script, that backups my databases, using mysqldump
via system().
When logged in with SSH, and launching the script with "./backup.php",
all works just as it should, but when I put it in a crontab:
00 2 * * * /home/sandman/bin/backup.php
I get a mail that says:
"mysqldump: Got error: 2002: Can't connect to local MySQL server
through socket '/var/run/mysqld/mysqld.sock' (2) when trying to
connect"
How come? Anyone knows what the difference is between CLI and crontab
that could cause this?
Well, for one thing, what's the user you have set up for your cron job?
Does it have permission to use the socket? Is it using the correct
socket?
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
In article <9f************ *************** ***@comcast.com >,
Jerry Stuckle <js*******@attg lobal.netwrote:
I have a PHP cli script, that backups my databases, using mysqldump
via system().
When logged in with SSH, and launching the script with "./backup.php",
all works just as it should, but when I put it in a crontab:
00 2 * * * /home/sandman/bin/backup.php
I get a mail that says:
"mysqldump: Got error: 2002: Can't connect to local MySQL server
through socket '/var/run/mysqld/mysqld.sock' (2) when trying to
connect"
How come? Anyone knows what the difference is between CLI and crontab
that could cause this?
Well, for one thing, what's the user you have set up for your cron job?
The same user I'm executing it with when it's working.
Does it have permission to use the socket? Is it using the correct
socket?
Well, after looking, the socket "/var/run/mysqld/mysqld.sock" doesn't
seem to exist. I realize I should have checked that first, but since
it worked before, I assumed that wasn't the problem.
There DOES exist a /tmp/mysql.sock file, and I have now set up my PHP
script with "mysqldump -S /tmp/mysql.sock" and I'll see in the morning
if it throws the same errors.
But how come mysqldump finds a correct socket when I'm running it from
the shell but not when I'm running it through crontab?
--
Sandman[.net]
Sandman wrote:
In article <9f************ *************** ***@comcast.com >,
Jerry Stuckle <js*******@attg lobal.netwrote:
>>>I have a PHP cli script, that backups my databases, using mysqldump via system().
When logged in with SSH, and launching the script with "./backup.php", all works just as it should, but when I put it in a crontab:
00 2 * * * /home/sandman/bin/backup.php
I get a mail that says:
"mysqldump : Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect"
How come? Anyone knows what the difference is between CLI and crontab that could cause this? Well, for one thing, what's the user you have set up for your cron job?
The same user I'm executing it with when it's working.
>>Does it have permission to use the socket? Is it using the correct socket?
Well, after looking, the socket "/var/run/mysqld/mysqld.sock" doesn't
seem to exist. I realize I should have checked that first, but since
it worked before, I assumed that wasn't the problem.
There DOES exist a /tmp/mysql.sock file, and I have now set up my PHP
script with "mysqldump -S /tmp/mysql.sock" and I'll see in the morning
if it throws the same errors.
But how come mysqldump finds a correct socket when I'm running it from
the shell but not when I'm running it through crontab?
Is it possible you have two copies of mysqldump on your system? The
cron job is probably running as a different user - and therefore would
have a different profile, among other things.
Or maybe it's picking up a different my.ini file.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== === This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Arkascha |
last post by:
Maybe someone can give me a short help with this...
I got a server application in a LAMP environment doing batch tasks. A
cronjob serves as a regular trigger, a metronom. The trigged
processcollects a number of pending jobs to be run and typically creates a
number of additional jobs to be run in future. The type of created jobs,
their...
|
by: Frank R. Suchy |
last post by:
Hi,
I want a php-script to maintain (some of) "my" cron jobs.
Therefore it has to modify some crontab.txt (no problem)
and has to execute crontab.
But since php runs as the apache-user it cannot run "my" crontab.
In general: Can a php-script run an external program under a different
|
by: Solange Ezveff |
last post by:
Hi,
Trying to restart MySQL when it is down.
I have placed the following script in a file :
checksql --->
#!/bin/sh
/etc/rc.d/init.d/mysqld status >/dev/null 2>&1
|
by: rbt |
last post by:
How can I safely append a crontab entry to a crontab file
progammatically with Python?
I need to handle crontabs that currently have entries and crontabs that
are empty. Also, I'd like this to work across Linux and BSD systems.
Any pointers?
|
by: David Garamond |
last post by:
I was thinking on how one would design an optimal (performance-wise)
database of large number of schedules with crontab-like semantic. There
will potentially be hundreds of thousands or even millions of "crontab"
entries, and there will be a query run once every minute to determine
which entries are to be run for that minute. The primary goal...
| |
by: the.natalie |
last post by:
Hi.
I am a newbie to mysql, cron, and shell scripting, so please bear with
me. I have a script that is used for updating an image directory based
on contents in a database. The script does the following: runs
several queries against different tables in a database; returns several
lists of pictures being used in the database; removes any...
|
by: dburdick |
last post by:
I was referred to this forum as this may be a php specific problem.
Some kind of configuration problem maybe.
I have some php files that connect to a mysql database and are run as
cron jobs.
The scripts work fine when run via the command line as root, but when
run via the cron they cause a mysql connection error.
Call to undefined...
|
by: Bob |
last post by:
Hi,
I would like to periodically start and stop mysql on a schedule using
something like the Windows scheduler. Does anyone know a good way to
do this?
Thanks,
Bob
|
by: Chr1s |
last post by:
How do I execute a crontab command using php (not CLI) as user Joe?
I don't have any problem getting output from commands such as 'ls'
using passthru and exec but I am stumped with crontab.
Many thanks!
Chris
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| | |