Jump to content

wrap a db2 sql command in a bash script so I can run it as a cron job


Recommended Posts

Posted

Im looking to create a bash script that I can call as a scheduled cron job to run a db2 command to manipulate a db2 database.

 

I know bash and cron well enough to get this part, but I dont know the db2 command line interface enough

 

I can run

 db2 connect to 

 

from the command line and establish a connection to the DB.

 

What I need to do, is establish a connection to the DB, and then run an SQL command such as:

 

INSERT INTO DB2INST1.TEST_SCHEDULE
(TIME, "SYSTEM")
VALUES
(current_timestamp, 'RB_test');

 

Is there a way to run each of these SQL commands using the db2 command line? Do I need to save this query into a .sql and run a specific command to execute it?

 

Hoping someone on here has some db2 from the bash cli experience who can help please :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...