Thread: running psql in a cron job

running psql in a cron job

From
Wei Weng
Date:
My database has "local all password" as its HBA control.

Is there anyway to manipulate psql so that I can somehow put the
password also inside the command line so that I can run psql in a cron
job? (such as psql -c "VACUUM ANALYZE" -d my_data -U my_user)

Thanks

-- 
Wei Weng
Network Software Engineer
KenCast Inc.




Re: running psql in a cron job

From
Wei Weng
Date:
never mind. a quick search in the mailing list archive solved the
problem. :)

Just use PGPASSWORD=my_pass psql -c "VACUUM ANALYZE" -d my_data -U
my_user


On Wed, 2002-08-07 at 10:51, Wei Weng wrote:
> My database has "local all password" as its HBA control.
> 
> Is there anyway to manipulate psql so that I can somehow put the
> password also inside the command line so that I can run psql in a cron
> job? (such as psql -c "VACUUM ANALYZE" -d my_data -U my_user)
> 
> Thanks
> 
> -- 
> Wei Weng
> Network Software Engineer
> KenCast Inc.
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org
> 
-- 
Wei Weng
Network Software Engineer
KenCast Inc.




Re: running psql in a cron job

From
Ignacio Coloma
Date:
Maybe I'm a bit lost: if cron is executed as root, then su <user> -c 
'command' would work without providing the password?

I mean, putting the password plain text anywhere doesn't seem that nice 
idea imho

Wei Weng wrote:

>never mind. a quick search in the mailing list archive solved the
>problem. :)
>
>Just use PGPASSWORD=my_pass psql -c "VACUUM ANALYZE" -d my_data -U
>my_user
>
>
>On Wed, 2002-08-07 at 10:51, Wei Weng wrote:
>  
>
>>My database has "local all password" as its HBA control.
>>
>>Is there anyway to manipulate psql so that I can somehow put the
>>password also inside the command line so that I can run psql in a cron
>>job? (such as psql -c "VACUUM ANALYZE" -d my_data -U my_user)
>>
>>Thanks
>>
>>-- 
>>Wei Weng
>>Network Software Engineer
>>KenCast Inc.
>>
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 6: Have you searched our list archives?
>>
>>http://archives.postgresql.org
>>
>>    
>>




Re: running psql in a cron job

From
Wei Weng
Date:
PGPASSWORD=my_pass sets the password to my_pass.

On Wed, 2002-08-07 at 14:02, Ignacio Coloma wrote:
> Maybe I'm a bit lost: if cron is executed as root, then su <user> -c 
> 'command' would work without providing the password?
> 
> I mean, putting the password plain text anywhere doesn't seem that nice 
> idea imho
> 
> Wei Weng wrote:
> 
> >never mind. a quick search in the mailing list archive solved the
> >problem. :)
> >
> >Just use PGPASSWORD=my_pass psql -c "VACUUM ANALYZE" -d my_data -U
> >my_user
> >
> >
> >On Wed, 2002-08-07 at 10:51, Wei Weng wrote:
> >  
> >
> >>My database has "local all password" as its HBA control.
> >>
> >>Is there anyway to manipulate psql so that I can somehow put the
> >>password also inside the command line so that I can run psql in a cron
> >>job? (such as psql -c "VACUUM ANALYZE" -d my_data -U my_user)
> >>
> >>Thanks
> >>
> >>-- 
> >>Wei Weng
> >>Network Software Engineer
> >>KenCast Inc.
> >>
> >>
> >>
> >>---------------------------(end of broadcast)---------------------------
> >>TIP 6: Have you searched our list archives?
> >>
> >>http://archives.postgresql.org
> >>
> >>    
> >>
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> 
-- 
Wei Weng
Network Software Engineer
KenCast Inc.




Re: running psql in a cron job

From
"Ross J. Reedstrom"
Date:
On Wed, Aug 07, 2002 at 06:02:39PM +0000, Ignacio Coloma wrote:
> Maybe I'm a bit lost: if cron is executed as root, then su <user> -c 
> 'command' would work without providing the password?
> 
> I mean, putting the password plain text anywhere doesn't seem that nice 
> idea imho

It's not the unix 'postgres' user's password: it's the database password
for the DB user - a completely independent user/password pair.

Ross

> 
> Wei Weng wrote:
> 
> >never mind. a quick search in the mailing list archive solved the
> >problem. :)
> >
> >Just use PGPASSWORD=my_pass psql -c "VACUUM ANALYZE" -d my_data -U
> >my_user