- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Housekeeping Scripts
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2001 11:37 PM
10-10-2001 11:37 PM
Housekeeping Scripts
I have to write a script which has to collect the directory names from the two columns from the table and that files has to be deleted for very 3 days starting with the name "X_"
Can any one help about this..
Thankingyou
Rajkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2001 11:52 PM
10-10-2001 11:52 PM
Re: Housekeeping Scripts
Please provide an example of the table.
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2001 12:59 AM
10-11-2001 12:59 AM
Re: Housekeeping Scripts
Thank you for your reply...
My table structure is like this..
create table CARD(card_id varchar2(10),
In_dir varchar2(255),
out_dir varchar2(255))
In the columns "In_dir" & "out_dir" users will store nearly upto 10 directory names.
For Example:
---------------
In_dir : /test_in1/oracle
: /test_in2/oracle
: /test_in3/oracle......upto /test10/oracle
Out_dir : /test_out1/oracle
: /test_out2/oracle
: /test_out3/oracle......upto /test10/oracle
So my script has to read the paths from the directories from the 2 columns and delete the files starting with "X_" for every 3 days only....After deleting the files it has to be written to the syslog file about the status of those files whether it was successfull or not...
Ok is it possible to read from the Database table.
If possible how can we select the path names from the CARD table & delete the files using Shell Script in HP-Unix 11.0
Thanks for the advance in help..
Regards
Rajkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2001 01:08 AM
10-11-2001 01:08 AM
Re: Housekeeping Scripts
Sorry, one more question. Does this table exist as a text file, and if so, can you attach an example. I need to know if each line only contains 3 entries, or if there are multiple directories listed per line.
Thanks, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2001 01:45 AM
10-11-2001 01:45 AM
Re: Housekeeping Scripts
I will give the complete picture
If i issue the select command the output will look like this....
SQL>select * from CARD;
card_id In_dir Out_dir
--------- --------- ----------
1d /test_in1/oracle /test_out1/oracle
2d /test_in1/oracle /test_out1/oracle
3d /test_in1/oracle /test_out1/oracle
4d /test_in1/oracle /test_out1/oracle
5d /test_in1/oracle /test_out1/oracle
6d /test_in1/oracle /test_out1/oracle
7d /test_in1/oracle /test_out1/oracle
8d /test_in1/oracle /test_out1/oracle
9d /test_in1/oracle /test_out1/oracle
10d /test_in1/oracle /test_out1/oracle
1)So the script has to pick up the directory names of the 2 columns from this table.
2)after that the shell script has to search for that directories path from the home directory of the system.
3)And it has to delete the files starting with "X_"
Is it possible to pickup from Oracle database table??
Thanks & Regards
Rajkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2001 02:27 AM
10-11-2001 02:27 AM
Re: Housekeeping Scripts
Something like this should do what you want:
cat tablename |grep oracle | while read cardid dir1 dir2 ; do
find $dir1 $dir2 -mtime +3 -name "X_*" | xargs rm
done
To check it is going to delete what you want, change the "xargs rm" to "xargs ls -ld"
I am not familiar with Oracle, so I can't answer your last question.
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2001 02:57 AM
10-11-2001 02:57 AM
Re: Housekeeping Scripts
there are several things that might be difficult with this structure:
- you need to make sure, that SQLPLUS sets the CHARWIDTH to maximum, to avoid that it clips needed information
- you need to parse for ":" to delimit.
if you want to stay with this structure, I would recommend to parse the SQLPLUS-output with awk, using ":" as a delimiter, but I would favor the following:
- add a serialnumber to the key
- if needed add an in/out attribute field
- just have one directory column
this would make a table like this:
id, ser, type, dir
1d, 1, 'i', /test_in1/oracle
1d, 2, 'i', /test_in2/oracle
1d, 3, 'o', /test_out1/oracle
And now, you can do a fine selection:
select 'rm ' || dir || '/X_*' from table where ... (whatever you want, id=, type= and so on)
You might need to set some SQLPLUS options to get rid of headings and so, but as a result, you could spool the output and run it later.
Hope this helps
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2001 03:35 AM
10-11-2001 03:35 AM
Re: Housekeeping Scripts
I just came across your other thread, and now I imagine, what you want to achieve.
I would change my recomendation, and modify it the following way:
Have an additional status column in that table, which can be tagged as "obsolete" by the application, if it has REALLY processed the file. I never like to have some time based restrictions on these type of interfaces, because some day (likely to be when some public holiday are grouped around a weekend) what intended to work will suddely do not, and maybe cause damage.
Interfaces should work with handshakes, not with hope, that something is already processed :-)
So if the application tags your record in this table as "yes, I processed it", your job can delete it for sure. You can then create your spooled delete script with "where status='processed'".
Just my 0.02?
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2001 05:33 AM
10-11-2001 05:33 AM
Re: Housekeeping Scripts
I assumed your in_directory1 column has the name which has to be removed.
cat > s.sql
set head off
set feedback off
spool /tmp/x
select in_dir from card where in_dir like '/test_in/oracle/X_%';
spool off
cd /test_in/oracle
sed 's\/test_in\/oracle//' /tmp/x.lst>/tmp/x1.lst
for i in `cat /tmp/x1.lst`
do
rm i
done
Please repeat the same for out_dir
Regds
jp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2001 06:58 PM
10-14-2001 06:58 PM
Re: Housekeeping Scripts
Thank you for your replies..I have tried with all your options but to some extent i have reached..but here I am not deleting any columns in the table..So i have the altenative way like this..
Once again i am repeating my query...
1) In the /app/sales directory i have so many files starting with the Prefix " X_filename.extension "
In this directory daily nearly upto 100 files will be generated using some other application...
So now i want to clean up only those files which starts with the letter "X_" for every 3 days and the message should be written to syslog.log in the directory /var/adm/syslog using the LOGGER command
Now i want to write a shell script using this method..
1) I have set an Enviromnent variable in HP-Unix11.0 like..
#env_dir=/app/sales
2) Now i want to write a shell script using the Environment variable "env_dir" . Because in this variable i have /app/sales directory..
3) so finally my scripts has to delete the files as said above using the variable " env_dir "..And in this directory i have so many files which starts with "X_"
Can you please provide me a script.....
Thanks for the advance in help..
Regards
Rajkumar