Link to home
Start Free TrialLog in
Avatar of Shakthi777
Shakthi777Flag for Afghanistan

asked on

Runing crontab jobs for postgres user ?

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 !
Avatar of duncanb7
duncanb7

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
Hi,
maybe this help you:

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

or

sudo su postgres -c "your commend  ... "
SOLUTION
Avatar of duncanb7
duncanb7

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of simon3270
simon3270
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shakthi777

ASKER

tnx !