Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by Shakthi777
at 2024-11-28 03:32:26
Point:500 Replies:5 POST_ID:828840USER_ID:11753
Topic:
Linux;Shell Scripting;PostgreSQL Database
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.
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 1:
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 !
Author: Shakthi777 replied at 2024-01-17 01:21:25
tnx !
Accepted Solution
Expert: simon3270 replied at 2024-12-01 13:14:09
250 points GOOD
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:/folderexec /folder/script1 -m srv1:5432 -s srv2:5432 -b /usr/lib/postgresql/9.2/bin 1:2:
Assisted Solution
Expert: duncanb7 replied at 2024-11-28 13:51:05
250 points GOOD
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
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
Expert: gwnet replied at 2024-11-28 13:28:02
Hi,
maybe this help you:
su postgres -c " your command eq. bash script "
or
sudo su postgres -c "your commend ... "
maybe this help you:
su postgres -c " your command eq. bash script "
or
sudo su postgres -c "your commend ... "
Expert: duncanb7 replied at 2024-11-28 03:57:37
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
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