By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 1,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

Run Unix Shell Scripts With Postgres Trigger

P: 1

I would like to run shell scripts with respect to the time mentioned in postgres data base tables. Postgres database should trigger the shell script for the time mentioned in the table. To make it more clear, i will add an entry like as below in postgres database table

file_id script_run_time 13:00

Now as part of automation process postgres database should trigger the script to run.

FYI, I know that i can write a shell script and put it in cron table to run continously so the script queries the table every minute and compare the extracted time from the table with the system date and trigger the extraction script which will be the subshell. But this would not be my automation requirement. Iam looking for a solution of triggering the script by looking the time in Postgres table.

Request all the masters in the forum to reply ASAP.

Thanks in advance and with Regards,
May 5 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 534
Postgresql is not the best tool to run the OS jobs and unfortunately I cannot think of any really smooth solution.

Look at the Postgresql job scheduler pgAgent.

Another approach could be to create a trigger on insert, update and delete for your table.
The function invoked by this trigger will get all rows from the jobs table and compile a crontab file out of them. Then it would submit the job and you're done. From that point on cron will take care of running your scheduled tasks.

When this table gets updated the trigger fires and your crontab file is recompiled and resubmitted. If all records are deleted the function will know how to call crontab to remove the job.

Obviously for this function you'll pick a language which has a way of running shell commands.
May 5 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.