Learn more about SQL Server tools

mssqltips logo
giveaway
 

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Whitepapers          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories

 

How to create SQL Server Agent Jobs on a Linux based instance using Management Studio


By:   |   Read Comments   |   Related Tips: More > SQL Server on Linux

Attend a SQL Server Conference for FREE >> click to learn more


Problem

SQL Server Agent support is included with the release of SQL Server vNext CTP 1.4. Now DBAs and users can schedule any task using a SQL Server Agent Job. I have explained how to create SQL Server Agent Jobs using T-SQL commands in a recent tip. In this tip, I will explain how to create and run SQL Server Agent Jobs using SQL Server Management Studio.

Solution

There is no difference between creating jobs on a Linux based SQL Server and a Windows based SQL Server using SQL Server Management Studio (SSMS).  The prerequisite to create and run jobs is to have SQL Server Agent installed on your SQL Server instance. I have explained the step by step process to install SQL Server Agent on Ubuntu server in a recent tip. SQL Server Agent Jobs are very useful for automating of any kind of repetitive task. You can get the full list of features and known issues at this Microsoft link: SQL Server on Linux Release Notes.

SQL Server Agent Job Creation using Management Studio

Before going ahead, you need to have SQL Server vNext running on your Linux based SQL Server. Also make sure that you have installed SQL Server Agent on this box to create jobs.

Step 1: First, connect to your Linux based SQL Server using SSMS from a Windows client. Enter the Linux server name/IP, then choose SQL Server authentication to enter the sa login and password. Click on the connect button to establish a database connection from the Windows client.

connect to Linux based SQL Server

You can see we have now connected to our target SQL Server machine.

Step 2: Now expand SQL Server Agent folder. You can see all the sub folders under SQL Server Agent folder. Right click on "Jobs" folder and choose "New Job..." to start the new job creation.

right click on jobs folder

Step 3: Once you click on the "New Job..." option the interface below will load. Complete the details including the name and description in the General tab of the interface.

new job creation wizard

Step 4: Now click on second tab "Steps" from left pane. You will get the below interface to add a new step.

create sql server job step

Click on "New" tab to add the step details. Once you click on the "New" button the below screen will appear to complete the step details. Enter the details as per your need. I am running a full backup for one of my databases, so I selected "Transact-SQL script (T-SQL)" as the Type and entered the T-SQL code which will be executed.

create sql server job

Once completed press the "OK" button to proceed. The will look like the screen shot below.

create sql server job

Step 5: Now click on third option "Schedules" from the left pane.

add job schedule

Click on "New" button to create a new schedule. You will get an interface similar to the below image. Enter the details as I have shown below to run the backup job on a daily basis.

add job schedule

Once you entered all the details click the "OK" button to proceed.

add job schedule

Step 6: Now you can check the job history to verify that this job has not run before.  Right click on the Job name and select the View History option.

Job History

Now go ahead and run this job. Right click on newly created backup job and click "Start Job at Step".

start the job

If the job successfully executes the window below will indicate success.

start the job

Step 7: Now we will validate the job success. We can check the job history as shown in the below image and can see backup job has been executed successfully.

job history

The final validation step is to check the newly created backup file on the Linux server. We can check the backup file location and we can see the newly created file.

check files
Next Steps


Last Update:


signup button

next tip button



About the author
MSSQLTips author Manvendra Singh Manvendra Singh has over 5 years of experience with SQL Server and has focused on Database Mirroring, Replication, Log Shipping, etc.

View all my tips
Related Resources





Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Notify for updates 


SQL tips:

*Enter Code refresh code     



Learn more about SQL Server tools