To Automate The Process of Running The
To Automate The Process of Running The
converting it to a CSV file, and sending it via email on a daily basis, you can create a shell script and use a
scheduler like `cron` to run it daily. Here's a step-by-step guide on how to do this:
Create a new shell script file, for example, `job_status_report.sh`, using a text editor:
```bash
nano job_status_report.sh
```
Inside the script file, you can use the following code to run the `bjobs -u all` command, save the output
to a CSV file, and send it via email using the `mail` command:
```bash
#!/bin/bash
# Run the bjobs command and save the output to a CSV file
recipient_email="[email protected]"
sender_email="[email protected]"
rm job_status.csv
```
Make sure to replace `[email protected]` and `[email protected]` with the actual email
addresses you want to use.
Save the file and make it executable using the following command:
```bash
chmod +x job_status_report.sh
```
Use `cron` to schedule the script to run daily. Open your crontab configuration:
```bash
crontab -e
```
Add the following line to run the script every day at a specific time (e.g., 9 AM):
```bash
0 9 * * * /path/to/job_status_report.sh
```
Replace `/path/to/` with the actual path to your script.
Now, your script will run the `bjobs -u all` command, save the output to a CSV file, and email it as an
attachment every day at the specified time. Make sure your server has `mail` or another mail client
configured for sending emails.
Note: Ensure that the server where you're running this script has the necessary permissions to execute
`bjobs`, create files, and send emails. Also, consider setting up proper email authentication and error
handling in your script for production use.
***********************************************************************************
Deployment Steps
1. I logged in to the QA server awsaiznva2223.jnj.com (SAS Grid QA Node 1) as a root user [sudo su
-]
2. Create a directory by using mkdir [name of directory] command.
3. Enter to the directory by using cd [name of directory] command
4. Create a file inside a directory by using touch [name_of_file.sh] command
5. We use ls command to see if the file is created.
6. To edit the newly created file we use vim [name_of_file.sh] command and then press I from
keyboard to insert code into the file, then we can paste our script which is copied from visual
studio.
7. Press Esc button from the keyboard and type :wq then press enter button to save the file.
8. To run our script we can use following command
./ [name_of_file.sh]