Crontab 使用實例

資料來源:https://linuxtools-rst.readthedocs.io/zh_CN/latest/tool/crontab.html

實例1:每1分鐘執行一次myCommand

* * * * * myCommand

實例2:每小時的第3和第15分鐘執行

3,15 * * * * myCommand

實例3:在上午8點到11點的第3和第15分鐘執行

3,15 8-11 * * * myCommand

實例4:每隔兩天的上午8點到11點的第3和第15分鐘執行

3,15 8-11 */2 * * myCommand

實例5:每週一上午8點到11點的第3和第15分鐘執行

3,15 8-11 * * 1 myCommand

實例6:每晚的21:30重啟smb

30 21 * * * /etc/init.d/smb restart

實例7:每月1、10、22日的4 : 45重啟smb

45 4 1,10,22 * * /etc/init.d/smb restart

實例8:每週六、週日的1 : 10重啟smb

10 1 * * 6,0 /etc/init.d/smb restart

實例9:每天18 : 00至23 : 00之間每隔30分鐘重啟smb

0,30 18-23 * * * /etc/init.d/smb restart

實例10:每星期六的晚上11 : 00 pm重啟smb

0 23 * * 6 /etc/init.d/smb restart

實例11:每一小時重啟smb

*/1 * * * /etc/init.d/smb restart

實例12:晚上11點到早上7點之間,每隔一小時重啟smb

0 23-7 * * * /etc/init.d/smb restart

Renaming a virtual machine and its files in VMware ESXi

Source : https://kb.vmware.com/s/article/1029513?docid=2094957

Rename the virtual disk (VMDK) files using the vmkfstools -E command:

# vmkfstools -E "originalname.vmdk" "newname.vmdk"

Notes

  • In some cases, it may be required to clone (copy) a virtual disk. To clone a virtual disk to a new virtual disk, run this command:

    # vmkfstools -i "originalname.vmdk" "newname.vmdk"

    This leaves the original virtual disk untouched. You need enough space available to clone the virtual disk in the destination directory. In the preceding command, the new virtual disk is created in the current directory but a different directory can be specified.
     
  • You need not rename the originalname-flat.vmdk file after running the vmkfstools command. The vmkfstools command renames both VMDK files and updates the reference within the descriptor.
     
  • Do not use the cp or mv commands to rename virtual disk files. Instead, use VMware utilities such as vmkfstools.

How do I find all files containing specific text on Linux with GREP?

Source: https://stackoverflow.com/questions/16956810/how-do-i-find-all-files-containing-specific-text-on-linux

Do the following:

grep -rnw '/path/to/somewhere/' -e 'pattern'
  • -r or -R is recursive,
  • -n is line number, and
  • -w stands for match the whole word.
  • -l (lower-case L) can be added to just give the file name of matching files.
  • -i stands for ignore case (optional in your case).

Along with these, --exclude--include--exclude-dir flags could be used for efficient searching:

  • This will only search through those files which have .c or .h extensions:grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
  • This will exclude searching all the files ending with .o extension:grep --exclude=\*.o -rnw '/path/to/somewhere/' -e "pattern"
  • For directories it’s possible to exclude one or more directories using the --exclude-dir parameter. For example, this will exclude the dirs dir1/, dir2/ and all of them matching *.dst/:grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"

This works very well for me, to achieve almost the same purpose like yours.

For more options check man grep.