In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Main problem: Beijing racing + car program + 1446595067 haozbbs.com
First: there is no problem with manual execution of .sh files, while scheduled task execution of .sh files indicates that you are not connected to the database.
Treatment method:
Add a sentence to the front of the script:
Source / .bash_profile
In this way, the operating environment is exactly the same. After adding this sentence, any script that can be executed successfully can be executed in crontab.
Second: the exported data is garbled, the excel2003 version is too low to open the cvs format file.
Third: the third question: did not get the current time (explained in more detail below)
Run crontab-e to write a scheduled task * / 5 * / home/test.sh to execute the test.sh script every 5 minutes.
Second, query the current user scheduled task or delete the current user scheduled task.
2.1 get the current date
The first one: declare variables
DATE= `date "+% Y%m%d" `
The above two points are to the left of the number 1. The plus sign should be close to the right, otherwise it will not be valid.
Reference: touch_$ {DATE} .txt
The second kind: direct use date
Touch `date +% Y% m% d`.txt
3. Direct orders
The first step is to have a startup shell, which is used for scheduled tasks to call and log output logs. The executeShell.sh code is as follows:
#! / bin/bash
DATE= `date +% Y% m% d`
SHELL_NAME= "shell.sh"
Echo "begin $SHLL_NAME---" `date` "-" > > / home/db2inst1/metadata_backup/$DATE.log
Shell_dir= "/ home/db2inst1/"
Cd $shell_dir
Sh $SHELL_NAME > > / home/db2inst1/metadata_backup/$DATE.log
# db2 connect to standard user metadata using metadata
The 3.2shell.sh shell is the key script to manipulate the database:
#! / bin/sh
Source / .bash_profile
Date= `date +% Y% m% d`
Rm-rf / home/db2inst1/metadata_backup/$ {date}
Cd / home/db2inst1/metadata_backup/
Mkdir / home/db2inst1/metadata_backup/$ {date}
Cd / home/db2inst1/metadata_backup/$ {date} /
Echo "start executing script"
If (db2 connect to database name user username using password > / dev/null)
Then
Echo "[info] db2 connection succeeded"
Db2 export to AAB01.ixf of ixf 'select * from AAB01'
# # #
Db2 export to AAB01.csv of del 'select * from AAB01'
Else
Echo "[info] db2 connection failed"
Exit 1
Fi
If (db2 connect reset > / dev/null)
Then
Echo "[info] db2 connection disconnected successfully"
Else
Echo "[info] db2 connection disconnect failed"
Fi
# cd / home/db2inst1/metadata_backup/
# tar-zcvf ${date} .tgz / home/db2inst1/metadata_backup/$ {date} /
# rm-rf / home/db2inst1/metadata_backup/$ {date}
IV. Achievement map
Reference:
Https://www.linuxidc.com/linux/2018-11/155189.htm
Https://blog.csdn.net/qq_28538407/article/details/81130737
Https://blog.csdn.net/alibo2008/article/details/7588046
-
Author: Gordan_
Source: CSDN
Original: https://blog.csdn.net/qq_36501591/article/details/86497280
Copyright notice: this article is the original article of the blogger, please attach a link to the blog article to reprint it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.