recent

Titulo

NOHUP for DBA & Developer

NOHUP is a Linux Command to run a job in the background. Why is it important to DBA and developer? NOHUP stands for "No Hang Up" which will make sense when you are done reading this article.  Whenever, I push a change to production database, we do it during off hours when there are no or minimum traffics that is mostly at midnight, early morning or weekends depending on the nature of business. I hate to go to office during those off hours to implement db changes therefore, I work from home using my VPN connection.

What are the risks of running your script from home? Well, I can list over dozens but I am going to point out just the main one.  You may loose your VPN connection anytime! What do you think? What will happen to the script you are running on your SQL Developer or SQL*Plus when you loose connection? Limbo right? Well, one of two things will happen, either the script will continue to run or the change gets rollback. Do you really want this to happen when you are working on a strict maintenance window? Well, I am going to show you how you can run your script in the background and not worry about your loosing VPN connection on both Linux & Window's Server.

Linux Server: Linux command <nohup> runs your script in the background. You don't have to wait for your script to be done running it. Just run the script in the background and move on to your next project.  Next, we will do a demo on how <nohup> command is used while running Linux shell script and in SQL*Plus to run SQL query.

vi demoscript.ksh
#!/bin/ksh
echo " no hup demo exercise"
echo "back from 1 min sleep"
sleep 60
echo "back from 5 min sleep"
sleep 300
exit
## making script executable
chmod 775 demoscript.ksh
## Running script in background
nohup ./demoscript.ksh &
## viewing background jobs
jobs


Foreground to Background: There may be a time where your script runs longer than expected time and you may need to leave for the day. In such case you must switch your foreground jobs to background and then log out.

## executing demoscript.ksh
./demoscript.ksh
## suspending execution of demo script.ksh
"CTRL +Z"
## switching foreground jobs to background
bg
## viewing background jobs
jobs
## bring background job back to foreground
fg %1


Running SQL Query in the Background:
nohup sqlplus username/password@oracleserver @query_file.sql &

Windows: Linux Server has a cool <nohup> utilities that takes care of everything we are trying to accomplish? What does Microsoft offer for their windows user? Well, there is no equivalent that I am aware of but I would always RDP into the Window's host where my database sits and run the deployment script using SQL*Plus from the command. You may even use SQL Developer if that is installed. If anyone knows the better alternatives, please post a comment below. Since, the query is running on the host, you can logout of your pc and then monitor from home later.

Others: What options do you have beside <nohup> and RDP? There are two other options that I am aware of but they require additional work. You may schedule your script to run via Cron Schedular. Cron runs all the process in the background. The second options is to run Oracle Query using DBMS Scheduler which runs the job in the background like Cron. When Linux is not your OS these are the second best options to run your scripts.

Now, you know the risk of running SQL queries from SQL Developer and SQL*Plus especially when working from home.  If I am working on queries that is going to take a long time at 4:00 pm, I will run my sql using <nohup>, exit my laptop, go home and then start monitor from home. I hope you find this article helpful and  I encourage you make to use it if you are working from home/remotely or deploying the critical changes.


Interested in working with me? I can be reached at pbaniya04[at]gmail.com for any questions, consulting opportunities or you may drop a line to say HELLO. Thank your again for visiting my blog and looking forward to serving you more.

Have a Database-ious Day!

77 comments

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. This comment has been removed by a blog administrator.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete
  10. This comment has been removed by a blog administrator.

    ReplyDelete
  11. This comment has been removed by a blog administrator.

    ReplyDelete
  12. This comment has been removed by a blog administrator.

    ReplyDelete
  13. very useful really good information thanks for posting such a good information it will hepls the people a lot keep it up.. Best MATLAB Training Center In Chennai|

    ReplyDelete
  14. very useful really good information thanks for posting such a good information it will hepls the people a lot keep it up , Regards, Best PMP Certification In Chennai|

    ReplyDelete
  15. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.and once again thanks for sharing.….. Best PMI Certification In Chennai|

    ReplyDelete
  16. Thanks for sharing this informative blog. I have read your blog and I gathered some valuable information from this blog. Keep posting. Best ISTQB BCS Certification In Chennai|

    ReplyDelete
  17. very nice post what a fantastic information you sharing. Keep sharing your post regularly.. Best CISM Certification in Chennai |

    ReplyDelete
  18. This post was quite awesome and interesting to read. Congrats for your work. Thanks a lot for providing this with us. Keep on updating this with us regularly: Best CISA Certification in Chennai |

    ReplyDelete
  19. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge. Best CCNA Training Center in Chennai |

    ReplyDelete
  20. Hi, am a big follower of your blog. The best thing is that your blog really informative thanks for your great information Best Microsoft Azure Training Center in Chennai |

    ReplyDelete
  21. Your blog was so informative, Really I thanks a lot for sharing such a awesome blog., Best RHCSA Training Institute In Chennai |

    ReplyDelete
  22. Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it. Best exchange server Training institute in chennai |

    ReplyDelete
  23. Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it. Best Tally Training Center in chennai |

    ReplyDelete
  24. Really an amazing post..! By reading your blog post i gained more information. Best Microsoft Advanced Excel Training Center in chennai |

    ReplyDelete
  25. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing. Best CCNA Training institute in chennai |

    ReplyDelete
  26. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing.. Best Software Testing Training Center in chennai
    |

    ReplyDelete
  27. this blog is really useful and it is very interesting thanks for sharing , it is really good and exclusive. Best Prince 2 Exam center in chennai|

    ReplyDelete
  28. Good one, it is very useful for me to learn and understand, thanks for sharing your information and ideas.. keep rocks.. Best Agile Scrum Master Exam center in chennai|

    ReplyDelete
  29. Great and useful post.Thanks for taking time to share this post. Best Machine Learning Training in chennai|

    ReplyDelete
  30. Great tips and its so easy to understand. really You explain everything in detailed manner and it was very interesting to read. Thank you. Best Data Science Training in chennai|

    ReplyDelete
  31. Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.… Best Oracle Certifications in Chennai |

    ReplyDelete
  32. Thanks for another great post. The place else may anyone get that type of information in such a perfect way of writing? I’ve a presentation next week, and I’m at the look for such information. Best CCNA Training Institute in Chennai

    ReplyDelete
  33. Wow, interesting and informative topic. Helps to gain a lot of knowledge . Thanks for posting such an informative post in this blog. Best Tally Training Institute in Chennai

    ReplyDelete
  34. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information and it is very useful to me... RHCSA Training Center in Chennai|

    ReplyDelete
  35. Great the given information and after refer that post,i get new energy because of all given information very excellent and real words to implemented for you.Thank you so much shared that valuable information. PCB Design Training Center in Chennai ! velachery|

    ReplyDelete
  36. Great the given information and after refer that post,i get new energy because of all given information very excellent and real words to implemented for you.Thank you so much shared that valuable information. PCB Design Training Center in Chennai ! velachery|

    ReplyDelete

  37. These provided information was really so nice,thanks for giving that post and the more skills to develop after refer that post. Your articles really impressed for me,because of all information so nice. JAVA Training Center in Chennai |

    ReplyDelete
  38. Thank you so much for sharing such an amazing post with useful information with us. Keep updating such a wonderful blog…. Photoshop Training institute in Chennai |

    ReplyDelete
  39. Nice blog, here I had an opportunity to learn something new in my field. I have an expectation about your future post so please keep updates. illustrator Training institute in Chennai |

    ReplyDelete
  40. Very nice blogs!!! I have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.… Tally Training Center in Chennai |

    ReplyDelete
  41. Very happy to see this blog. Gives a wonderful information with coded explanaion. Thank you for this blog. very useful to me. Prince2 Certification Center in Chennai |

    ReplyDelete
  42. Thanks for your informative Information.Your post helped me to understand the future and career prospects. Keep on updating your blog with such awesome article. Agile Scrum Master Certification Center in Chennai |

    ReplyDelete
  43. Thanks for sharing this informative blog. I have read your blog and I gathered some valuable information from this blog. Keep posting. BBA Project center in chennai and velachery |

    ReplyDelete
  44. Awesome post. Really you have shared a very informative concept... Thank you for sharing. Keep on updating... EEE Project center in chennai and velachery |

    ReplyDelete
  45. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas. UFT Training center in chennai |

    ReplyDelete
  46. Hi, you have given really informative post. Thanks for sharing this post to our vision. MCSE Training institute in chennai |

    ReplyDelete
  47. It is really a great and useful piece of information. I am glad that you shared this helpful info with us. Please keep us up to date like this. Thank you for sharing. Azure Training institute in Chennai and Velachery |

    ReplyDelete
  48. Amazing write up. You have delivered useful information. Thanks for posting and keep blogging. PCB Design Training Center in Chenna |

    ReplyDelete
  49. Excellent blog with useful concept. Really I feel very happy to see this informative blog, Thanks for sharing such a nice blog.. Tally Training Institute in Chennai|

    ReplyDelete
  50. Very nice post here and thanks for it .I always like and such a super blog of these post.Excellent and very cool idea and great blog of different kinds of the valuable information's. Python Training Institute in Chennai |

    ReplyDelete
  51. awesome way to get exert tips from everyone,not only i like that post all peoples like that post,because of all given information was wonderful and it's very helpful for me. CCNA Exam Center in Chennai |

    ReplyDelete
  52. In the beginning, I would like to thank you much about this great post.I like your writing style and I hope you will keep doing this good working AWS Exam Center in Chennai |

    ReplyDelete
  53. Wow...Excellent informative blog, really helpful. Thank you. Final Year Projects For Phd in Chennai |

    ReplyDelete
  54. It is really a great work and the way in which u r sharing the knowledge is excellent.Thanks for helping me to understand basic concepts. Final year projects For Engineering Students in Chennai |

    ReplyDelete
  55. Thank you for sharing the information here. Its much informative and really i got some valid information. You had posted the amazing article. Final year projects For CSE Students in Chennai |

    ReplyDelete
  56. Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it. Final year projects For CS in Chennai |

    ReplyDelete
  57. I am joyful to read this post, its an attractive one. Thanks for this amazing post.. Final year projects For IT in Chennai |

    ReplyDelete
  58. I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.. Final year projects For EEE in Chennai |

    ReplyDelete
  59. this blog is really useful and it is very interesting thanks for sharing , it is really good and exclusive. PMP Certification Center in Chennai |

    ReplyDelete
  60. This is excellent information. It is amazing and wonderful to visit your site.Thanks for
    sharing this information, this is useful to me. Photoshop Training institute in Chennai |

    ReplyDelete
  61. Really an awesome post. I wondered by reading this blog post. Thanks a lot for posting this unique post which you have shared with us. Keep on posting like this exclusive post with us. Photoshop Training institute in Chennai |

    ReplyDelete
  62. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!PCB Design Training in Chennai |

    ReplyDelete
  63. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Hardware and Networking Training institute in Chennai |

    ReplyDelete
  64. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information and it is very useful to me... Microsoft Azure Certification Center in Chennai |

    ReplyDelete
  65. Really very great information to be provided and the All points discussed were worth reading and i’ll surely work with them all one by one. TOGAF Certification Center in Chennai |

    ReplyDelete
  66. Wonderful blog.. Thanks for sharing informative blog.. its very useful to me.. Selenium Training Center in Chennai |

    ReplyDelete
  67. Your blog was so informative, Really I thanks a lot for sharing such a awesome blog. Tally Erp9 Training Center in Chennai |

    ReplyDelete
  68. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly. Graphic Designing Training Center in Chennai |

    ReplyDelete
  69. Nice Post! It is really interesting to read from the beginning & I would like to share your blog to my circles, keep your blog as updated. JAVA Training Institute In Chennai |

    ReplyDelete
  70. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing. Final year projects For EEE in Chennai |

    ReplyDelete
  71. Impressive blog with lovely information. really very useful article for us thanks for sharing such a wonderful blog... Final year projects For BCA in Chennai |

    ReplyDelete
  72. Your blog is awesome..You have clearly explained about it ...Its very useful for me to know about new things..Keep on blogging.. Final year projects For MCA in Chennai |

    ReplyDelete
  73. Python is a dynamic and object-oriented programming language, widely used for web application development. 90% of people prefer Python over other technology because of its simplicity, reliability and easy interfacing. unindent does not match any outer indentation level python

    ReplyDelete

Powered by Blogger.