當前位置:首頁 » 網頁前端 » 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