Mschedule Simple Linux process Management (Raspberry Pi)

Source: Internet
Author: User

Raspberry Pi is a magical machine, the CPU and memory are poor, but small volume of low power consumption, on the above to engage in some of the West is actually very interesting, quite fun. is Pidara, basic service is not streamlined how much, first cat CPU and RAM.

[[email protected] ~]$ cat/proc/cpuinfo processor:armv6-compatible Processor Rev 7 (v6l) bogomips:46  4.48FEATURES:SWP half thumb fastmult vfp edsp java TLS CPU implementer:0x41cpu ARCHITECTURE:7CPU variant: 0X0CPU part:0xb76cpu revision:7hardware:bcm2708revision:000eserial:00000000312           3ffdc[[email protected] ~]$ cat/proc/meminfo memtotal:446672 kbmemfree:289976 kBBuffers: 16872 kbcached:65868 kbswapcached:0 kbactive:88652 kbinactive:50360 kbacti           ve (anon): 58692 kbinactive (anon): 844 kbactive (file): 29960 kbinactive (file): 49516 kbunevictable: 0 kbmlocked:0 kbhightotal:0 kbhighfree:0 kblowtotal:446672 KBLOWFR             ee:289976 kbswaptotal:524284 kbswapfree:524284 kbdirty:16 kbwriteback:      0 Kbanonpages:   56284 kbmapped:16088 kbshmem:3268 kbslab:9684 kbsreclaimable:5664 Kbsun                reclaim:4020 kbkernelstack:656 kbpagetables:1292 kbnfs_unstable:0 kbbounce: 0 kbwritebacktmp:0 kbcommitlimit:747620 kbcommitted_as:211148 kbvmalloctotal:565248 kBVmal  locused:5024 kbvmallocchunk:347144 kb[[email protected] ~]$
    The Raspberry Pi may be to save costs, and there is no time module installed, so each boot time will be reset. Because the iron has not been moved for a long time, so I did not think of it to install a hardware module.
So the idea is to synchronize network time. Start with a startup script, start the synchronization time, but every time the machine restarts, half an hour will not start, and even if it started, there is no
Synchronization time. So think of the second method, with root user crontab, the results do not know why, no synchronization, crontab perform other tasks is no problem, the reason is unclear.
    Another problem, because the Raspberry Pi is connected by a network cable Tp-link route, while there is a millet box attached. Millet box is a magical thing, only you connect on the route of Tp-link, the other
Computers or mobile devices can be difficult to connect to, even if the millet box is disconnected, the situation is still unresolved. So, the elder sister to see the connection is not on, unplug the power to restart. Some applications can be made self-booting,
But not all programs are as perfect as nginx, which switches the user to execute.
    Another problem is that some programs coredump, let it restart automatically, the system configuration does not seem to be possible (can be done). I also want to run a DHT crawler on top of the Raspberry Pi, but the DHT crawler takes up too much
Network, if kept open, the network is basically obsolete. So I want to be in Monday to five hours before the start of operation, until 17 o'clock stopped, can be configured and so on.
    Based on the above requirements, I have a very simple management scheduler, features:
    1. Three types of procedures can be managed, the resident process (hangs automatically restarts), a process (responsible for starting, regardless of success), a priority process (responsible for the start, regardless of success, with the highest
       Priority, so the program must wait until such programs exit before other programs are started)
    2. You can specify the user to run and must have the appropriate permissions
    3. The resident process can configure the run time.
    Disadvantages:
    1. No priority assigned to each process
    2. No dependencies are designed without a process
  Related configuration files:
[[email protected] bin]$ cat mysch.conf #程序运行参数 # program configuration segment prog_list configuration #[nginx] #程序启动的命令 #run_command=/sbin/ntpdate 1. cn.pool.ntp.org# the user group running the program #run_group=nginx# the user running the program #run_user=nginx# program run Flag #-1 program starts after waiting for it to run complete before running other programs # 0 after the program starts regardless of its running state # 1 The program runs according to Run_time configuration point in time, non-operating point automatically stops through the kill signal #run_flag=1#run_flag=1 valid, program run time period, week (1-7), time format (24 hours), between the conditions is or relationship #run_time =1-5,23:30-16:30|1-5,17:30-21:30|6-7,00:00-8:30[common] #日志路径LOG_PATH =/home/nginx/bin/log# Log Header log_header= schedule# file Log level all,debug,info,warn,error,fatal,offlog_level=debug# file log cache,bytelog_buffer=102400# file switch time, seconds log_switch_time=86400# sleep time Sleep_time = 60# Eject when the subroutine Kill_child_flag = 1#pid file, Effective pid_file=/home/nginx/bin/log/mysch.pid# run When the console is executed run_user=rootprog_list=ntp| Nginx| Bigfalse[ntp]run_command=/usr/sbin/ntpdate 1.cn.pool.ntp.orgrun_user=rootrun_flag=-1[nginx]run_command=/home/ nginx/www/sbin/nginxrun_user=nginxrun_flag=1run_time=1-7,00:00-24:00run_pid_file=/home/nginx/www/logs/ nginx.pid[bigfalse]run_command=/usr/bin/python/home/nginx/tinytrue/manage.py runfcgi host=127.0.0.1 port=7856 Daemonize=truePidfile=/home/nginx/tinytrue/log/django.pid Outlog=/home/nginx/tinytrue/log/access.log errlog=/home/nginx/ tinytrue/log/error.logrun_user=nginxrun_flag=1run_time=1-7,00:00-24:00run_pid_file=/home/nginx/tinytrue/log/ Django.pid
    Follow this configuration to run the program:
[[email protected] bin]$ p nginxroot 233 1 0 14:41?        00:00:00/home/nginx/bin/mysch-c/home/nginx/bin/mysch.confnginx 304 1 0 14:42?        00:00:00 nginx:master Process/home/nginx/www/sbin/nginxnginx 305 304 0 14:42?        00:00:00 Nginx:worker Process nginx 307 1 0 14:42? 00:00:00/usr/bin/python/home/nginx/tinytrue/manage.py runfcgi host=127.0.0.1 port=7856 daemonize=truePidfile=/home/nginx/tinytrue/log/django.pid Outlog=/home/nginx/tinytrue/log/access.log errlog=/home/nginx/        Tinytrue/log/error.lognginx 308 307 0 14:42? 00:00:00/usr/bin/python/home/nginx/tinytrue/manage.py runfcgi host=127.0.0.1 port=7856 daemonize=truePidfile=/home/nginx/tinytrue/log/django.pid Outlog=/home/nginx/tinytrue/log/access.log errlog=/home/nginx/        Tinytrue/log/error.lognginx 309 307 0 14:42? 00:00:00/usr/bin/python/home/nginx/tinytrue/manage.py runfcgi host=127.0.0.1 port=7856 daemonize=truePidfile=/home/nginx/tinytrue/log/django.pid Outlog=/home/nginx/tinytrue/log/access.log errlog=/home/nginx/        Tinytrue/log/error.lognginx 310 307 0 14:42? 00:00:04/usr/bin/python/home/nginx/tinytrue/manage.py runfcgi host=127.0.0.1 port=7856 daemonize=truePidfile=/home/nginx/tinytrue/log/django.pid Outlog=/home/nginx/tinytrue/log/access.log errlog=/home/nginx/        Tinytrue/log/error.lognginx 311 307 0 14:42? 00:00:06/usr/bin/python/home/nginx/tinytrue/manage.py runfcgi host=127.0.0.1 port=7856 daemonize=truePidfile=/home/nginx/tinytrue/log/django.pid Outlog=/home/nginx/tinytrue/log/access.log errlog=/home/nginx/        Tinytrue/log/error.lognginx 312 307 0 14:42? 00:00:10/usr/bin/python/home/nginx/tinytrue/manage.py runfcgi host=127.0.0.1 port=7856 daemonize=truePidfile=/home/nginx/tinytrue/log/django.pid Outlog=/home/nginx/tinytrue/log/access.log errlog=/home/nginx/ Tinytrue/log/error.log
    Related code:
  Https://github.com/buf1024/mysch
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.