-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShell Scripting
More file actions
95 lines (79 loc) · 2.43 KB
/
Copy pathShell Scripting
File metadata and controls
95 lines (79 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#Author=
#Purpose=
#Creation date=
#Modificaton date=
# creating the of file with previous date and time
#touch -d "Mon 5 June 2021 12:23:15" Oldfile{1..5}.txt
# find the 90 days old files
#find /var/log -mtime +90 -exec ls -l {} \;
# rename the old files
#find /opt/scripts -mtime +90 -exec mv {} {}.new \;
# Deleting the old 90 days files
#find /opt/scripts -mtime +90 -exec rm {} \;
# archive the file , compress and move to the remote host or remote destination
#tar -cvf /tmp/backup.tar /var/log
#gzip /tmp/backup.tar
#find /tmp/backup.tar.gz -mtime -1 -type f -print &> /dev/null
#if [ $? -eq 0]
#then
#echo "backup sucess created"
#echo " archive also created"
#scp /tmp/backup.tar.gz root@172.168.10.44:/data/backupstorage
#else
#echo "backup failed"
#fi
# To known the login user details
# echo "please enter day (e.g Mon)"
#read day
#echo "please enter Month (e.g jun)"
#read Month
#echo "please enter date (e.g 17)"
#read date
#echo
#last | grep "$day $month $date"
#last
# To check the current date
#echo "Current time is $(date)"
# find the file with .txt and move to .html
#filename=`find /tmp/scripts/ -name "*.txt" | cut -d "." -f1`
#for i in $filename
#do
#mv $i.txt $i.html
#done
#To check the size of file in directory
dir=/tmp
#for file in $dir/* ;
#do
#echo "file $file is $(stat --printf='%s' $file) Bytes."
#done
#du -sh /tmp
#To check the service status
read -p "Enter your of service=" service
status=$(systemctl status $service)
echo -e "this show the status\033[96m $status\033[0m" # \033[88m is print in color where you select
#!/bin/bash
#This is used to start and stop httpd service
read -p "Enter start,stop,status,enabled,and Disabled to perform action on httpd service: " action
read -p "Enter the Service name=" Service_name
Systemtcl=$(systemctl ${action} ${Service_name})
if [ "${action}" == "start" ]
then
echo "${action} ${Service_name}...."
echo"$Systemtcl" #echo"$Systemtcl" # systemctl ${action} $(Service_name)
echo "${action} ${Service_name}"
fi
if [ "${action}" == "stop" ]
then
echo "${action} ${Service_name}"
echo "$Systemtcl" # systemctl ${action} $(Service_name)
# systemctl ${action} $(Service_name)
echo "${action} ${Service_name}"
fi
if [ "${action}" == "status" ]
then
echo "stopping ${Service_name}..."
echo"$Systemtcl" # systemctl ${action} $(Service_name)
# systemctl ${action} $(Service_name)
echo "${action} ${Service_name}"
fi