batch command just make different commands run simultaneously
terminal:
1) run batch command, then we are allowed to put in the command list will be put into the batch queue
2) Put in two following commands then type Ctrl D
./script_1
echo "Hello world!" > temp2.txt
3) List the temp file generated. Both files are generated.
4 - 5) Print out the file content
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ batch
warning: commands will be executed using /bin/sh
at> ./script_1
at> echo "Hello world!" >temp2.txt
at> <EOT>
job 18 at Sun Jul 27 15:24:00 2014
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ ls -lrt temp*
-rw-rw-r-- 1 aubinxia aubinxia 13 Jul 27 15:25 temp.txt
-rw-rw-r-- 1 aubinxia aubinxia 13 Jul 27 15:25 temp2.txt
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ cat temp.txt
Hello world!
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ cat temp2.txt
Hello world!
2. crontab
crontab is used to run specified command at scheduled time, it is very helpful run some "maintaining tsk" which needs to run multiple times at different time period.
crontab file format:
mm hh dd mon weekeday command
00-59 00-23 01-31 01-12 0-6(0=Sunday)
hyphen means range, * means every choice
owntab:
1) First line means that system should run ls command every minute
2) Second line means that system should run ls command at every Sunday's 23:15
0-59 * * * * ls >>/home/aubinxia/Desktop/xxdev/temp.txt
15 23 * * 0 ls >>/home/aubinxia/Desktop/xxdev/temp.txt
terminal:
1) -l option make crontab list current tab schedule
2) If there is no schedule now, we add our own owntab schedule
3) After some minutes, print out the content of temp.txt, we found that crontab is working now, it starts output the content into temp.txt. Based on its content, we can know that crontab is running the command at user's home directory.
4) Use -r option to remove the current tab schedule
5) Use -l option to list current tab schedule, we find that all schedules have been removed.
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ crontab -l
no crontab for aubinxia
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ crontab owntab
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ cat temp.txt
Desktop
Documents
Downloads
examples.desktop
Music
Pictures
Public
script_1
script_1~
Templates
Videos
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ crontab -r
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ crontab -l
no crontab for aubinxia
No comments:
Post a Comment