crontab

进程和计划任务管理

我的未来我决定 提交于 2019-11-28 16:12:44
本次给大家介绍的是进程和计划任务管理 一、查看进程 二、控制进程 三、at一次任务设置 四、crontab周期服务设置 一、查看进程 程序和进程的关系 1、保存在硬盘、光盘等介质中的可执行代码和数据 2、静态保存的代码 进程 1、 在CPU及内存中运行的程序代码 2、动态执行的代码 3、父、子进程:每个进程可以创建一个或多个进程 相关命令 ps命令-查看静态的进程信息 a:查看当前系统的所有进程 u:指定用户 x:该用户在所有终端下的进程 -e:显示系统内的所有进程信息 -l:使用长格式显示进程信息 -f:使用完整的格式显示进程信息 例如 命令ps-aux:简单列表的形式显示出进程信息 命令ps-elf:以长格式显示系统中的进程信息,输出信息还包括PPID列 实际操作 1、用ps-aux查看当前root的静态进程。 其中USER指当前用户;PID 为进程号(PID为1的是init); %CPU、%MEN指cpu的占用率、内存占用率;VSZ、RSS为虚拟内存、物理内存占用;TTY : 终端(?为未知、大多本地加载为?);STAT : 当前进程状态(S可中断休眠进程、D不可中断休眠进程、s父进程、<代表优先级高、R运行进程、l代表多线性、N优先级低、Z僵尸进程、+前台进程);START:为启动时间;Time:进程占用CPU的总时间;Command :进程名称。 2、用ps

CentOS 7计划任务管理

和自甴很熟 提交于 2019-11-28 16:07:18
一、at一次性任务设置 使用at命令设置的计划任务只在指定的时间执行一次,前提是对应的系统服务at必须已经运行。 例如我们设置任务在2019-8-26 18:40执行。 到了时间记得对任务的执行结果进行验证。 那要当我们有错误或不想要的任务时那又该怎么办呢?这时候就需要用到atrm命令了。 二、crontab周期性任务设置 crontab的配置文件 使用crontab命令管理用户的计划任务 使用“crontab -e”后,将打开计划任务编辑界面。 进入任务编辑界面后可以自行添加我们想执行的计划任务配置。 这里我们添加里一个任务配置。 当我们不想执行这些计划任务时可以使用“crontab -r”进行清空,如果当我们想具体删除某条计划任务时可以通过“crontab -e”进入任务编辑界面进行删除。 来源: https://blog.51cto.com/14449528/2432741

Linux任务调度(8)

大憨熊 提交于 2019-11-28 14:42:52
crond任务调度:   是指系统在某个时间执行特定的命令或程序。   分类:1、系统工作,有些重要的工作必须周而复始地执行,如病毒扫描等;2、个别用户工作,个别用户可能希望执行某些程序,如mysql数据库备份 基本语法:   crontab [选项]   [-e] 编辑crontab定时任务   [-l] 查询crontab任务   [-r] 删除当前用户所有的crontab任务 案例:/etc/crontab      */1 * * * * ls -l /etc >> /tmp/to.txt : 没分钟向to.txt中添加内容   参数细节说明:     * 表示任何时间,比如第一个*代表一个小时总每分钟都执行一次     , 代表不连续的时间,如"0 8,12,16 * * *"代表每天8点0分、12点0分、16点0分执行一次命令     - 代表连续的时间范围,如"0 5 * * 1-6"代表每周一至周六的凌晨5点0分执行命令     */n 代表每隔多久执行一次。如上述示例中代表每隔一分钟执行一次命令 通过文件脚本进行设置任务:   1、编写shell脚本,如vim /home/mytask.sh     date >> /tmp/mydate   2、给mytask.sh一个可执行的权限     chmod 744 /home/mytask.sh   3

crontab计划任务注意事项

血红的双手。 提交于 2019-11-28 12:34:33
计划任务注意事项 1、at 这个是一次性的计划任务,应该很少用 2、crontab 周期性计划任务 计划任务没有执行的原因可以通过mail邮件分析 计划任务可以实现让指定用户执行某条命令 # 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、最好在计划任务前面写上PATH=...指定PATH路径,否则经常报错找不到命令,只能绝对路径 2、带有特殊字符的计划任务,比如含有百分号,最好放入shell脚本中,再写入计划任务 3、crontab使用vim作为默认编辑器。见下面 良好的习惯: [root

Crontab fails to execute Python script

喜夏-厌秋 提交于 2019-11-28 12:14:31
crontab fails to execute a Python script. The command line I am using to run the Python script is ok. These are solutions I had tried: add #!/usr/bin/env python at the top of the main.py add PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin at the top of crontab chmod 777 to the main.py file service cron restart my crontab is: PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin */1 * * * * python /home/python_prj/main.py and the log in /var/log/syslog is: Nov 6 07:08:01 localhost CRON[28146]: (root) CMD (python /home/python_prj/main.py) and nothing else. The main.py script calls some methods

date +“%Y-%m-%d” in crontab

喜你入骨 提交于 2019-11-28 12:14:12
问题 If I put the following in crontab -e : * * * * * date +"%Y-%m-%d" > /home/apps/temp/env.txt there is no env.txt created. If I change the above line to: * * * * * date > /home/apps/temp/env.txt env.txt is created properly. How can I format date in cron? 回答1: You need to escape each one of the % : * * * * * date +"\%Y-\%m-\%d" > /home/apps/temp/env.txt Or even better, remove the quotes and leave like this: * * * * * date +\%Y-\%m-\%d > /home/apps/temp/env.txt 来源: https://stackoverflow.com

running php scripts locally though task manager

寵の児 提交于 2019-11-28 11:24:26
问题 I'm looking for some advice. Rignt now i've got a bunch of php scripts that i've scheduled through cron. They run on my local machine doing stuff like pulling stuff out of a mysql db and sending automated emails. To run them I just have something like this in crontab: 0 7 * * 1 /usr/bin/php /phpscripts/script.php I need to migrate all of those scripts to a Windows machine. I'm planning to use the Windows Task Scheduler to run the scripts, but how can I run the actual php scripts locally? From

Does cron expression in unix/linux allow specifying exact start and end dates

自闭症网瘾萝莉.ら 提交于 2019-11-28 10:55:48
I want to be able to configure something like this. I want to run job 'X' at 7 AM everyday starting from 29/june/2009 till 30/12/2009. Consider current date as 4/4/2009. It can be done in a tricky sort of way. You need three separate cron jobs for that range, all running the same code ( X in this case): one for the 29th and 30th of June ( "0 7 29,30 6 * X" ). one for every day in the months July through November ( "0 7 * 7-11 * X" ). one for all but the last day in December ( "0 7 1-30 12 * X" ). This gives you: # Min Hr DayOfMonth Month DayOfWeek Command # --- -- ---------- ----- --------- --

execute crontab twice daily at 00h and 13:30

房东的猫 提交于 2019-11-28 10:42:51
i want to execute a script twice daily at 00:00 and 13:30 so i write : 0,30 0,13 * * * it seems wrong for me, because like this, the script will fire at 00:00 , 00:30 , 13:00 and 13:30. Any idea ? Why not put in two cron entries ? One for 00:00 and one for 13:30 ? I don't think you can do what you want in one entry, since the two minute definitions will apply for both hour definitions (as you've identified). The alternative is perhaps to execute one script at 00:00. That script would execute your original script, then wait 13.5 hours and then execute that script again. It would be easy to do

linux debian crontab job not executed

人走茶凉 提交于 2019-11-28 10:14:23
I have a bash script foo.sh located in the /etc/cron.daily directory, chmoded 700, owned by root, crontab list for the root user is unchanged (crontab -l) from the core Debian installation. I did run cronjob in another way than crontab -l and/or crontab -e (eg I did not restart cron daemon with /etc/init.d/cron as adviced in the specific Debian's case). Despite a test job file is running under similar conditions. The script is debugged and can be run as a standalone task without returning errors. I've also checked logs (/var/log/syslog) and nothing wrong in there. But : this particular job is