设置linux的自动关机和windows的自动关机(篇幅一)

一、在linux下设置自动关机:(服务器版CentOS-7.2系统,硬件:X86平台)
1.1、关机配置脚本路径:
[root@localhost home]# cat /etc/crontab
1.2、关机配置脚本内容:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .—————- minute (0 - 59)
# | .————- hour (0 - 23)
# | | .———- day of month (1 - 31)
# | | | .——- month (1 - 12) OR jan,feb,mar,apr …
# | | | | .—- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
1.3、关机配置通过man查询命令细节如下:
[root@localhost home]# man 4 crontabs
CRONTABS(4) Crontabs users’ Manual CRONTABS(4)

        NAME -- crontabs - configuration and scripts for running periodical jobs

        SYNOPSIS -- run-parts [--list|--test]<directory>

        DESCRIPTION -- Crontabs  is  a historical name for the run-parts script and the system crontab. 
                The run-parts script runs all executables in the specified directory.Run-parts runs all 
                by creating file jobs.allow  or jobs.deny which worked similar as other allow/deny config 
                files. The file must be created in the specified directory.

               --list print names of all files (not limited to executables), but don't run them. This option 
               can't be used with test option.

               --test print names of files, which would be run.

                      Randomization  of jobs can be configured in the /etc/sysconfig/run-parts file. To enable
                       randomization of jobs, set the RANDOMIZE parameter
                      to 1 and set the RANDOM parameter to an integer which determines a random seed. Additionally, 
                      you may configure  the  RANDOMTIME  parameter
                      (again,  by  specifying an integer) to provide an additional level of randomization. Jobs are
                       not randomized when the RANDOM and RANDOMTIME
                      parameters are set to 0. Values in these two parameters must be set to 1 or larger to provide a
                       good enough randomization.

                      Randomization of cron jobs can be useful for shared networks, where multiple cron jobs executed 
                      at once can cause spikes in traffic,  especially during daily jobs. With randomized jobs, the 
                      orkload is evenly distributed throughout the day.

        EXAMPLE OF CONFIGURATION FILE
               RANDOMIZE=1
               RANDOM=4
               RANDOMTIME=8

               Historically  the  crontab file contained configuration which called run-parts on files in cron.
               {daily,weekly,monthly} directories. These jobs are
               now run indirectly through anacron to prevent conflicts between cron and anacron.  That means the 
               anacron package has to be installed if the  jobs
               in these directories should be running. Refer to the anacron(8) how to limit the time of day of the job
                execution.

        EXAMPLE
               /etc/cron.daily/jobs.deny could contain for example 0logwatch which forbid execution of this script.

        SEE ALSO
               anacron(8), crontab(5)

        Marcela Mašláňová                                                       2012-08-29

1.4、实际操作结果
在命令窗口执行:crontab -e 进入编辑模式,
依照1.2的提示输入要执行的命令。
CentOS下自带命令如下:
1.4.1、使用方式:
crontab [options] file
crontab [options]
crontab -n [hostname]
1.4.2、操作选项(1.4.1中的 ‘options’):
-u define user 指定执行账户
-e edit user’s crontab 编辑执行命令
-l list user’s crontab 查看可执行用户账户
-r delete user’s crontab 删除某个账户的自启命令
-i prompt before deleting 立即执行(不询问)
-n set host in cluster to run users’ crontabs 设置集群情况下的核心机
-c get host in cluster to run users’ crontabs 集群情况下执行核心机的脚本
-s selinux context 安全模式执行
-x enable debugging 允许调试开机程序
1.4.3、测试效果:
Broadcast message from root@localhost
(unknown) at 17:29 …
The system is going down for halt NOW!
1.4.4、一些调试用到的东西:
a、crontab依赖linux的开机自启服务:crond;
b、如果没有该服务,只要可以执行crontab也可以说明已经安装该服务,服务名可能被隐藏。
c、查看本机是否支持cronb服务:

篇幅限制,下接 “设置linux的自动关机和windows的自动关机(篇幅二)”

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
要开发一个打车软件,需要考虑以下几个方面: 1. 后端服务器:打车软件需要一个后端服务器来存储用户数据,车辆位置和司机信息等。可以使用各种编程语言和框架实现后端服务器,比如Python,Java,Node.js等。在Linux下,我们可以使用Nginx或Apache等Web服务器来部署后端服务器。 2. 数据库:后端服务器需要一个数据库来存储用户信息和订单数据等。MySQL、PostgreSQL和MongoDB等都是很好的选择。 3. 前端应用程序:打车软件需要一个前端应用程序来让用户进行订单预订,查看订单状态等。前端应用程序可以使用React、Angular或Vue.js等框架来实现。 4. 地图服务:打车软件需要使用地图服务来定位车辆和用户的位置,以及计算距离和费用等。Google Maps、Baidu Maps和高德地图等都是很好的选择。 下面是一个简单的打车软件的后端服务器程序示例,使用Python和Flask框架实现: ```python from flask import Flask, request import json app = Flask(__name__) # 存储车辆位置和司机信息 drivers = { "1": {"name": "张三", "location": [39.92, 116.46]}, "2": {"name": "李四", "location": [39.93, 116.47]}, "3": {"name": "王五", "location": [39.94, 116.48]}, } # 存储订单信息 orders = [] @app.route('/api/drivers', methods=['GET']) def get_drivers(): return json.dumps(drivers) @app.route('/api/orders', methods=['POST']) def create_order(): data = request.json orders.append(data) return json.dumps({"success": True}) if __name__ == '__main__': app.run(debug=True) ``` 这个程序有两个路由: - `/api/drivers`:获取所有车辆位置和司机信息。 - `/api/orders`:创建一个新订单。 对于前端应用程序和地图服务的实现,由于篇幅限制,无法全部展示,可以参考相关文档和教程进行开发。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值