Home IT Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ 3 tips Linux command     - How to implement large-scale distributed Yahoo depth study on the Hadoop cluster (Server)

- Use Linux built-in firewall to improve network access control (Linux)

- Linux unpack the tar file to a different directory (Linux)

- Lua4.0 interpreter documents (Programming)

- Linux IO redirection (Linux)

- How to set cache valid time in Apache (Server)

- Linux System Getting Started Learning: DeVeDe installed on Linux to create a video DVD (Linux)

- Linux Shell Scripting Interview Question (Linux)

- SELinux security permissions HTTP + PHP service changes (Server)

- Installation of Theano + CUDA under Ubuntu (Linux)

- ActiveMQ5.11.1 and JDK version matching relation (Linux)

- Ubuntu UFW firewall settings Introduction (Linux)

- JVM garbage collector and memory allocation strategy (Programming)

- Depth understanding of the use of Spring Redis (Programming)

- Bitmap memory footprint of computing Android memory optimization (Linux)

- Memcache explain in detail (Server)

- Installation and operation GAMIT software under Linux operating system (Linux)

- Fedora 20 users install the Mate 1.8 desktop (Linux)

- Java semaphores (Programming)

- vector C ++ sequence containers (Programming)

  3 tips Linux command
  Add Date : 2018-11-21      
  Linux world is full of fun, the more we go in depth, you will find more interesting things. We will try to give you some tips so that you and others are different, here is what we prepared three small skills.

1. How does the case of using the task scheduler Cron under Linux in

In Linux, a task scheduler / command called Cron. When we need to schedule a task, we will use Cron, but you know we're not used Cron also can schedule a task to run in the future of time? You can follow the following suggested actions ......

Run a command every 5 seconds (date) and then writes the results to a file (data.txt). To achieve this, we can run the following one-line script directly from the command prompt.

$ Whiletrue; do date >> date.txt; sleep 5; done &
Above script explanation:

while true: let the script enters a loop condition is always true, that is manufacturing a dead cycle, repeated over and over again inside the command to run.
do: do while statement is a keyword, the command will be executed after it, it can be placed behind one or a series of commands.
date >> date.txt: Run date command and writes its output to the data.txt file. Note that we use >> instead of>.
>>: File (date.txt) additions to the write operation, so that after each run command, the output will be appended to the file. If> then this will overwrite the previous content over and over again.
sleep 5: the script to sleep in five seconds, and then run the command later. Note that the only time unit in seconds. This means that if you want the command to run once every 6 minutes, you should use the sleep 360.
done: while loop end of the block tag.
&: The entire process into the background.
Similarly, we can run any script. The example below is run every 100 seconds a script called script_name.sh of.

Also worth mentioning is the script file mentioned above must be in the current directory, or need to use the full path (/home/$USER/.../script_name.sh). One-line script to achieve the above functions as follows:

$ Whiletrue; do / bin / sh script_name.sh; sleep 100; done &
Summary: The above is not a one-line script Cron alternatives because Cron tool supports many options, more flexibility, customization is also higher. However, if we want to run some tests, such as I / O evaluation, said one-line script is also useful.

2. How does the use of clear command to clear the contents of the terminal

How do you empty the contents of the terminal? You might think this is a silly question. Well, we all know you can use the clear command. If you develop using ctrl + l shortcuts habit, we will save a lot of time.

Ctrl + l effect shortcut and clear commands. So the next time you can use ctrl + l to empty the contents of the terminal.

Summary: Because ctrl + l is a shortcut, we can not use in the script. So if we need to empty the contents of the screen in the script, or the need to use the clear command. But I can think of all the other cases, ctrl + l are more effective.


3. Run a command in a different directory, then automatically return to the current working directory

This is a lot of people may not know the amazing skills. You might want to run any command in a different directory, then back to the current directory. To achieve this purpose, you only need to put a command in parentheses.

Let's look at an example:

avi @ deb: ~ $ (cd / home / avi / Downloads /)
Sample output:

avi @ deb: ~
It will first cd to the Downloads directory, then back to the previous home directory. Maybe you think the inside of the command is not executed, or that something is wrong, because from the command prompt do not see any change. Let's look at a simple modification of this order:

avi @ deb: ~ $ (cd / home / avi / Downloads / && ls -l)
Sample output:

-rw-r ----- 1 avi avi 54272May318: 37 text1.txt
-rw-r ----- 1 avi avi 54272May318: 37 text2.txt
-rw-r ----- 1 avi avi 54272May318: 37 text3.txt
avi @ deb: ~ $
In the above command, it first entered the Downloads directory, then list the contents of the file, and finally back to the current directory. And it proves that the command executed successfully. You can include any command in parentheses, will be executed after the successful return to the current directory.
- To install Oracle Database Details and FAQ Summary under CentOS (Database)
- Java multi-threaded in a three way (inheritance, implementation, anonymous inner classes) (Programming)
- Java code JIT compiler-friendly Mody (Programming)
- Linux System Getting Started Learning: Linux command in w (Linux)
- Ubuntu U disk do not have write privileges can only read but not write (Linux)
- Ubuntu 12.04 64bit Install Source Insight 3.5 and create desktop icons (Linux)
- The difference between Linux su and sudo commands (Linux)
- Intel Graphics Installer installation on Ubuntu 15.10 (Linux)
- CentOS 6.5 installation and configuration Cobbler (Server)
- JavaScript cross-browser event object library (Programming)
- PostgreSQL Select source code analysis (Database)
- Linux use iptables ban Ping (Linux)
- CentOS terminal display Chinese (Linux)
- Elaborate 10-point difference between the new and malloc (Programming)
- Macro Analysis Performance: PHP Performance Analysis and Experiment (Programming)
- Fedora 20 Installation and Configuration (Linux)
- Ubuntu method for single-card dual-IP (Linux)
- The difference between equals and == in Java (Programming)
- Security implementation of disk data protection under Linux (Linux)
- To use Linux to create a secure managed gateway (Linux)
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.