Обсуждение: Crontab problem with backup
I was trying to backup a database called "old_db".The following lines inserted into either root crontab file or postgres crontab file failed either to produce any output or created an empty file caled "old_db_hr9.tgz" in the /backups/hour/ directory.. 0 9 * * 1-5 postgres pg_dump --format=t old_db > /backups/hour/old_db_hr9.tgz 0 18 * * 5 postgres pg_dump --format=t old_db > /backups/week/old_db_friday.tgz What logs do I need to check to find the problem? What might be a way to test the script?
On April 14, 2006 06:58 pm, Kirti <kirti@unswalumni.com> wrote: > What logs do I need to check to find the problem? Wherever your system logs the output from cron. RedHat Linux and derivatives will have a /var/log/cron or something similar (if you happen to be running Linux). The postgres user probably got email about it, too. > What might be a way to > test the script? su - postgres run the command This will uncover most problems, outside of obscure path differences between a normal login session and what cron provides. Also make sure the user is allowed to execute cron jobs. Your cron log most likely will tell you what went wrong, though. -- Alan
Kirti <kirti@UNSWalumni.com> writes: > I was trying to backup a database called "old_db".The following lines > inserted into either root crontab file or postgres crontab file failed > either to produce any output or created an empty file caled > "old_db_hr9.tgz" in the /backups/hour/ directory.. > 0 9 * * 1-5 postgres pg_dump --format=t old_db > > /backups/hour/old_db_hr9.tgz > 0 18 * * 5 postgres pg_dump --format=t old_db > > /backups/week/old_db_friday.tgz Are you sure you've got the crontab file format correct? On my machine, at least, there's no userid column. regards, tom lane
Tom Lane wrote: > Kirti <kirti@UNSWalumni.com> writes: > > I was trying to backup a database called "old_db".The following lines > > inserted into either root crontab file or postgres crontab file failed > > either to produce any output or created an empty file caled > > "old_db_hr9.tgz" in the /backups/hour/ directory.. > > > 0 9 * * 1-5 postgres pg_dump --format=t old_db > > > /backups/hour/old_db_hr9.tgz > > > 0 18 * * 5 postgres pg_dump --format=t old_db > > > /backups/week/old_db_friday.tgz > > Are you sure you've got the crontab file format correct? On my machine, > at least, there's no userid column. That is a BSD-ism. -- Bruce Momjian http://candle.pha.pa.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
At 12:28 AM 4/15/06, Bruce Momjian wrote: >Tom Lane wrote: > > > > Are you sure you've got the crontab file format correct? On my machine, > > at least, there's no userid column. > >That is a BSD-ism. Not true. A username column is included in /etc/crontab on both Linux and BSD systems.
At 02:33 AM 4/17/06, Andrej Ricnik-Bay wrote: > > >That is a BSD-ism. > > Not true. A username column is included in /etc/crontab on both Linux and > > BSD systems. > >Not true. > >Not in Dillon's Cron (the one that comes with Slackware) ... >And there's not even an /etc/crontab file, to begin with. Thanks, I suppose I have not exposed myself to enough Linux distros. Before this morning, I was not aware there were a number of different cron packages available on Linux. vixie-cron (used by SuSE) supports the username column in /etc/crontab On OpenBSD, there is not a /etc/crontab "to begin with"; but create one (with correct permissions) and it starts working. I've used MDK and RH, but didn't use /etc/crontab on those systems. Frank