Thread: Cronjob to autobackup database
i have a cronjob setting up as below 1)Command crontab -e 2)Keyin 30 09 * * * /autopgdump.sh 3) Save to new crontab file. but nothing happen, the backup process won't start. i manage to perform manual backup by running the following command sudo ./autopgdump.sh( SH file store under root directory looking for the correct ways to setting up the cronjob. thanks -- View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873.html Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
Here is a crontab example. I always specify the absolute path. 0 0 * * * /postgresql/home/scripts/backup/backup_wal_enabled_instance.sh inst1 5432 Peter Krawetzky -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of teyking2003 Sent: Monday, December 03, 2012 8:13 PM To: pgsql-admin@postgresql.org Subject: [ADMIN] Cronjob to autobackup database i have a cronjob setting up as below 1)Command crontab -e 2)Keyin 30 09 * * * /autopgdump.sh 3) Save to new crontab file. but nothing happen, the backup process won't start. i manage to perform manual backup by running the following command sudo ./autopgdump.sh( SH file store under root directory looking for the correct ways to setting up the cronjob. thanks -- View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873.html Sent from the PostgreSQL - admin mailing list archive at Nabble.com. -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin This e-mail may contain confidential or privileged information. If you think you have received this e-mail in error, please advise the sender by reply e-mail and then delete this e-mail immediately. Thank you. Aetna
You can debug what's going wrong with the script by adding this: 30 09 * * * /autopgdump.sh &> /autopgdump.log that will write the output of the command to a logfile living at /autopgdump.log. If there's anything wrong with your environment(something not in the PATH of the user running the cron, etc) it should be written there. Cron runs with a slightlydifferent environment than a regular login shell, so this can help you figure out exactly what's going wrong. note: each time cron executes that script, it will replace the contents of /autopgdump.log; not append to it. Also, just to double check, the above configuration would run the script at 9:30am every day, so did you wait until 9:30for the script to run? ...spike On Dec 3, 2012, at 8:13 PM, teyking2003 wrote: > i have a cronjob setting up as below > 1)Command crontab -e > 2)Keyin 30 09 * * * /autopgdump.sh > 3) Save to new crontab file. > but nothing happen, the backup process won't start. > > i manage to perform manual backup by running the following command > sudo ./autopgdump.sh( SH file store under root directory > > looking for the correct ways to setting up the cronjob. > > thanks > > > > -- > View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873.html > Sent from the PostgreSQL - admin mailing list archive at Nabble.com. > > > -- > Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-admin
so if i putting the .SH files under root directory the cronjob will look similar like 30 09 * * * /root/autopgdump.sh please advice? -- View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873p5735088.html Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
Try by below method: 30 09 * * * sh /autopgdump.sh These should work. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873p5735118.html Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
Ahh. When you said "root" I thought you meant "/". Yes, if in /root, then /root/autopgdump.sh You must specify absolute path in cron. ...spike (Sent via handheld, please pardon spelling errors) On Dec 4, 2012, at 7:48 PM, teyking2003 <tchongking@hotmail.com> wrote: > so if i putting the .SH files under root directory > the cronjob will look similar like > 30 09 * * * /root/autopgdump.sh > > please advice? > > > > -- > View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873p5735088.html > Sent from the PostgreSQL - admin mailing list archive at Nabble.com. > > > -- > Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-admin
i copy this copy inside etc/cron.daily/autopgdump.sh and put in the full directory path and wait until 930am. but nothing has been process. do we need to setup special permission for this .SH file? -- View this message in context: http://postgresql.1045698.n5.nabble.com/Cronjob-to-autobackup-database-tp5734873p5735397.html Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
A question -- >________________________________ > From: teyking2003 <tchongking@hotmail.com> >To: pgsql-admin@postgresql.org >Sent: Wednesday, December 5, 2012 4:39 PM >Subject: Re: [ADMIN] Cronjob to autobackup database > >i copy this copy inside etc/cron.daily/autopgdump.sh and put in the full >directory path and wait until 930am. but nothing has been process. > >do we need to setup special permission for this .SH file? > If you copy the command exactly as the cron entry shows it, and, as the user who runs the cron job, paste it onto the commandline and run it; what does the command do ? If it runs from the command line, a few possibilities occur to me -- a) you didn't set the time to what you thought you did (been there, done that, easy to do). b) Some missing part that the user's environment is providing (an ENV var, for example) but the cron job would not know about. If it does not run from the command line, that will probably give you a clue. HTH, Greg Williamson