Asked By
bakerj82
200 points
N/A
Posted on - 07/22/2011
Hi,
I am using the Informix database with dbaccess data_base_name. Could you please let me know how to execute a SQL query every month end without modification of the query? For example every end of month I have a dozen of SQL queries to be executed and I have to send the results to my colleagues but I have to edit each of them to modify the period from Day 1 to Day 30 if it’s November or from Day 1 to Day 31 if it’s December, etc.
How should I write these fields in my SQL script?
Thanks.
Execute SQL query ever end of month
Hi,
It is pretty simple as I have done so on numerous occasions on windows as well as on Linux. To schedule a job, it does not have to be inside a query all the time. In windows you can use Power Shell Script to schedule a query to run at a specific time, however, in case of informix, please add the query to a bash script/shell script and then add it to a crontab:
$ crontab -l
Add your script in crontab and then allocate hour, minute, second and if configured correctly, you will have no problems with the month ending being 30 day or 31 days as crontab runs off the system time. Hope that helps.
Cheers