?
Solved

Runing crontab jobs for postgres user ?

Posted on 2013-11-28
5
Medium Priority
?
2,180 Views
Last Modified: 2014-01-17
Hi Experts,

I need to run some script over my Postgres database by postgres user. So, I have set a cron tab to execute it for every 5 minutes.

*/5 * * * * /folder/script1 -m srv1:5432 -s srv2:5432 -b /usr/lib/postgresql/9.2/bin

Open in new window


script1=the file containing my script

But its not running. I can't root's crontab since it's not allowed in Postgres service.

Can you kindly help me on this and thanks a lot for your time !
0
Comment
Question by:Shakthi777
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 13

Expert Comment

by:duncanb7
ID: 39683328
Did you run your script at linux shell directly and successfully ?

If yes, maybe you need to add it in your script

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/opt/usr/bin:/opt/usr/sbin:/usr/local/bin:/usr/local/sbin;
/yourscriptlocation;"   which is just example only

and it might also need to do  " chmod 755 yourscript"

Hope understand your question completely, if not , please point it out

Duncan
0
 
LVL 1

Expert Comment

by:gwnet
ID: 39684216
Hi,
maybe this help you:

su postgres -c " your command eq. bash script "

or

sudo su postgres -c "your commend  ... "
0
 
LVL 13

Assisted Solution

by:duncanb7
duncanb7 earned 750 total points
ID: 39684234
Shakthi777,

Be reminded, output all stuff including error/warning  generated from script to
a file, post_error.log by the following cron-job setting that will help
to debug your issue in post_error.log

*/5 * * * * /folder/script1 -m srv1:5432 -s srv2:5432 -b /usr/lib/postgresql/9.2/bin >post_error.log


Duncan
0
 
LVL 19

Accepted Solution

by:
simon3270 earned 750 total points
ID: 39688639
Also, some crontabs have a command length limit - yours (particularly if the script isn't actually in the quite short /folder/script1 J) might be too long.  Try having a wrapper script called, say, /folder/script2 whcich you call with no arguments, and that contains just:
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/folder
exec /folder/script1 -m srv1:5432 -s srv2:5432 -b /usr/lib/postgresql/9.2/bin

Open in new window

0
 

Author Closing Comment

by:Shakthi777
ID: 39787918
tnx !
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month12 days, 23 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question