当前位置:首页 » 网页前端 » crontab脚本后台不运行
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

crontab脚本后台不运行

发布时间: 2022-11-04 08:22:33

㈠ crontab里面的任务怎么也不执行

1. 新增crontab中的任务
oracle@BI-DB-HIS:/expdata/rpt/scripts$crontab -e
"/var/tmp/aaa002939" 7 lines, 496 characters
0 10 * * * /expdata/rpt/scripts/create_snapshot.sh>/dev/null 2>&1
"/var/tmp/aaa002939" 7 lines, 497 characters
warning: commands will be executed using /usr/bin/sh
2. 到10点中的时候,任务没有执行,手工执行多次,确认没有问题
3. 查看.sh和.sql的权限问题,确认也没有问题
4. google到crontab 是不会根据用户自动搜索环境变量的,man的信息如下:
Users who desire to have their .profile executed must explicitly do so
in the crontab entry or in a script. called by the entry.
5. 在.sh脚本中加入export 环境变量
原始脚本:
oracle@BI-DB-HIS:/expdata/rpt/scripts$more /expdata/rpt/scripts/create_snapshot.sh
sqlplusleiz/mleiz@bidb @/expdata/rpt/scripts/create_snapshot.sql

oracle@BI-DB-HIS:/expdata/rpt/scripts$more /expdata/rpt/scripts/create_snapshot.sql
exec dbms_workload_repository.create_snapshot();
exit;

更新后脚本
oracle@BI-DB-HIS:/expdata/rpt/scripts$vi create_snapshot.sh
"create_snapshot.sh" 1 line, 70 characters
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/proct/10.2/db
export ORACLE_SID=bidb
export PATH=/usr/bin:/etc/:/usr/sbin:/usr/ucb:/usr/local/bin:$ORACLE_HOME/bin:/usr/bin/X11:/sbin:$PATH
export NLS_LANG=american_america.ZHS16GBK

sqlplusleiz/mleiz@bidb @/expdata/rpt/scripts/create_snapshot.sql
6. man crontab
oracle@BI-DB-HIS:/expdata/rpt/scripts$man crontab

crontab(1) crontab(1)

NAME
crontab - user job file scheler

SYNOPSIS
crontab [file]

crontab -e [username]

crontab -l [username]

crontab -r [username]

DESCRIPTION
The crontab command manages a crontab file for the user. You can use
a crontab file to schele jobs that are executed automatically by
cron (see cron(1M)) on a regular basis. The command has four forms:

crontab [file] Create or replace your crontab file by
ing the specified file, or standard
input if file is omitted or - is specified
as file, into the crontab directory,
/var/spool/cron/crontabs. The name of
your crontab file in the crontab directory
is the same as your effective user name.
If the compartmentalization feature is
enabled, the crontab file is your
effective user name followed by a colon
(:), followed by the compartment id from
which the crontab file is created.

crontab -e [username] Edit a of the user's crontab file, or
create an empty file to edit if the
crontab file does not exist. When editing
is complete, the file will be copied into
the crontab directory as the user's
crontab file. If the compartmentalization
feature is enabled, it only edits a
of the user's crontab file from the
compartment that the crontab files were

㈡ 你好,关于crontab配置shell脚本不执行的问题能帮忙解答下不

先试试直接执行shell脚本,如果ok,那就是因为你没有引入用户的环境变量,在脚本开始加一句 . ~/.profile引入用户环境变量即可。
如果你这个用户直接执行shell都不成功,就是shell本身的问题,和crontab没关系。

㈢ linux 普通用户crontab周末不运行

并不是写法问题,实际上cron不执行很有可能是你在对语句拷贝粘贴的过程中出现了不合法的字符。你可以讲上述语句注释掉,然后重新手工输入一次,也许就解决了。 你目前的脚本没有任何输出,你怎么知道判断没有执行成功呢?在你是shell脚本中加个

㈣ linux crontab -e 不执行

17:47 看第二条,不是已经执行了么?
假设你网络配置没有任何语法错误(这个最好确认下,特别是没有用nmtui配置的);
你这个逻辑有一个很大的问题:假如这个network服务8.30前是start的,那你那个start就没有意义了;建议可以用restart替代试试,如果还是不行,可以写成一个.sh,执行脚本看看。
你这个需求有点奇葩,一般没人会禁用网卡

㈤ linux下的crontab配置后怎么不能执行

经验之谈:
1、查看语法是否错误,如分钟取值范围为 0-59; 小时取值范围 0-23;最多5列时间单位等。
2、查看crond进程是否启动。

3、查看/var/log/cron日志,确定脚本是否在需要的时间内执行了。
4、由于环境变量原因,脚本中的命令尽量写全路径,如 touch 写成 /bin/touch;ftp 写成 /usr/bin/ftp; 或者在脚本中增加完整的用户环境变量引用。

㈥ crontab中启动的shell脚本不能正常运行,但是使用手动执行没有问题

1、这种情况多数为环境变量加载问题
2、例如你用ls命令,其实依赖PATH环境变量
3、可以改为全路径,比如/bin/ls
4、或者将环境变量加载到脚本
#!/bin/sh
. ~/.bash_profile
ls -lrt $*

㈦ linux crontab里指向了一个脚本,但时间到不执行

首先检查一下用户权限问题 ,比如 crontab的守护进程有没有权限使用root用户来执行程序等等

其次 要用 crontab -e 添加 ,不要直接编辑/etc/crontab文件

㈧ 使用crontab,定时执行一个python脚本,怎么不能用

先把你的代码贴一下看看,格式上有没有什么问题.

一般常见的crontab不能执行是因为找不到运行的环境,因为crontab运行命令跟我们在命令行里直接运行的条件是不一样的.

你能运行python不代表crontab就能找到运行python的软件,找到python脚本的位置.所以最好都用绝对路径,python所在的目录和你的脚本所在的目录.

如果用了还没有找到,就尝试用shell包装一下再运行,一般也能解决的

㈨ linux oracle用户不执行crontab定时脚本

是不是放计划任务后
没有登录环境就报错了
sh -x yourshell &>log
这样看看是不是有报错。如果按你上面的报错,应该是没有bash权限,或者脚本格式不对

㈩ crontab 计划任务不运行是咋回事

一、系 统的Cron计划文件存放在/etc/crontab路径下。与用户的crontab文件不同,root用户可以直接对该文件进行修改,而不用使用 crontab -e命令。除此之外,系统crontab文件中任务的定义也有所不同,在前五个部分之后插入了一个“用户”部分。以下是我的/etc/crontab文 件: # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron ( cd / && run-parts --report /etc/cron.monthly ) # 二、使设置生效 设置完成后,重启cron即可使设置的计划任务定时执行了,重启命令如下: service cron restart