linux at命令无效,Linux“at”命令在從shell運行時工作正常,但從webserver運行時失敗...

I'm using "at" in order to set future actions set by users on RHEL6.4. The command I'm using from php is

我正在使用“at”來設置用戶在RHEL6.4上設置的未來操作。我從php使用的命令是

exec("echo \"php $script_path\" | at $run_time");

where the script path has been set as has the run time. This works 100% fine when I run from a shell initiated with php -a. When it runs from the webserver the job is created, but it doesn't seem to run.

腳本路徑已設置為運行時的位置。當我從一個用php -a啟動的shell運行時,這可以100%正常工作。當它從Web服務器運行時,創建了作業,但它似乎沒有運行。

I have verified : The apache user has full read-write-execute access to the directory and all folders therein.

我已經驗證:apache用戶具有對目錄及其中所有文件夾的完全讀寫 - 執行訪問權限。

The exec command is running (the at job is created, after all.)

exec命令正在運行(畢竟創建了at作業。)

I have verified the job is looking for the right path on the server.

我已經驗證了該作業正在服務器上尋找正確的路徑。

I'm not sure what else I can do to get this at command to run the script properly. Any suggestions?

我不知道還能做些什么來讓這個命令正確地運行腳本。有什么建議么?

Thank you for your help.

感謝您的幫助。

Update: I went ahead and created a page that linked to the script I'm trying to auto-run and launched it in that way. The script itself works fine when run as apache that way, meaning it's definitely something that "at" is doing. I ran print_r($_ENV) to determine the environment variables being used. The only thing that shows up is a number 1.

更新:我繼續創建了一個鏈接到我試圖自動運行並以這種方式啟動它的腳本的頁面。當這種方式以apache運行時,腳本本身工作正常,這意味着它肯定是“at”正在做的事情。我運行了print_r($ _ ENV)來確定正在使用的環境變量。唯一出現的是數字1。

Update 2: I ran an at -c on each job, the one that never seems to run, and the one that works just fine. There seems to be much more content on the one that does work VS the one that doesn't. 65 worked (ran from shell)

更新2:我在每個工作上運行了一個-c,一個似乎永遠不會運行的工作,以及一個工作正常的工作。似乎有更多的內容在那個有效的VS和那個沒有的內容上。 65工作(從殼跑)

at -c 65

#!/bin/sh

# atrun uid=0 gid=0

# mail root 0

umask 22

HOSTNAME=ipdb-sys.ipdb.lab; export HOSTNAME

SHELL=/bin/bash; export SHELL

HISTSIZE=1000; export HISTSIZE

SSH_CLIENT=143.166.167.124\ 53008\ 22; export SSH_CLIENT

QTDIR=/usr/lib64/qt-3.3; export QTDIR

QTINC=/usr/lib64/qt-3.3/include; export QTINC

SSH_TTY=/dev/pts/0; export SSH_TTY

USER=root; export USER

LS_COLORS=rs=0:di=01\;34:ln=01\;36:mh=00:pi=40\;33:so=01\;35:do=01\;35:bd=40\;33\;01:cd=40\;33\;01:or=40\;31\;01:mi=01\;05\;37\;41:su=37\;41:sg=30\;43:ca=30\;41:tw=30\;42:ow=34\;42:st=37\;44:ex=01\;32:\*.tar=01\;31:\*.tgz=01\;31:\*.arj=01\;31:\*.taz=01\;31:\*.lzh=01\;31:\*.lzma=01\;31:\*.tlz=01\;31:\*.txz=01\;31:\*.zip=01\;31:\*.z=01\;31:\*.Z=01\;31:\*.dz=01\;31:\*.gz=01\;31:\*.lz=01\;31:\*.xz=01\;31:\*.bz2=01\;31:\*.tbz=01\;31:\*.tbz2=01\;31:\*.bz=01\;31:\*.tz=01\;31:\*.deb=01\;31:\*.rpm=01\;31:\*.jar=01\;31:\*.rar=01\;31:\*.ace=01\;31:\*.zoo=01\;31:\*.cpio=01\;31:\*.7z=01\;31:\*.rz=01\;31:\*.jpg=01\;35:\*.jpeg=01\;35:\*.gif=01\;35:\*.bmp=01\;35:\*.pbm=01\;35:\*.pgm=01\;35:\*.ppm=01\;35:\*.tga=01\;35:\*.xbm=01\;35:\*.xpm=01\;35:\*.tif=01\;35:\*.tiff=01\;35:\*.png=01\;35:\*.svg=01\;35:\*.svgz=01\;35:\*.mng=01\;35:\*.pcx=01\;35:\*.mov=01\;35:\*.mpg=01\;35:\*.mpeg=01\;35:\*.m2v=01\;35:\*.mkv=01\;35:\*.ogm=01\;35:\*.mp4=01\;35:\*.m4v=01\;35:\*.mp4v=01\;35:\*.vob=01\;35:\*.qt=01\;35:\*.nuv=01\;35:\*.wmv=01\;35:\*.asf=01\;35:\*.rm=01\;35:\*.rmvb=01\;35:\*.flc=01\;35:\*.avi=01\;35:\*.fli=01\;35:\*.flv=01\;35:\*.gl=01\;35:\*.dl=01\;35:\*.xcf=01\;35:\*.xwd=01\;35:\*.yuv=01\;35:\*.cgm=01\;35:\*.emf=01\;35:\*.axv=01\;35:\*.anx=01\;35:\*.ogv=01\;35:\*.ogx=01\;35:\*.aac=01\;36:\*.au=01\;36:\*.flac=01\;36:\*.mid=01\;36:\*.midi=01\;36:\*.mka=01\;36:\*.mp3=01\;36:\*.mpc=01\;36:\*.ogg=01\;36:\*.ra=01\;36:\*.wav=01\;36:\*.axa=01\;36:\*.oga=01\;36:\*.spx=01\;36:\*.xspf=01\;36:; export LS_COLORS

WEBROOT=/var/www; export WEBROOT

MAIL=/var/spool/mail/root; export MAIL

PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/dell/srvadmin/bin:/opt/dell/srvadmin/sbin:/root/bin; export PATH

PWD=/root; export PWD

LANG=en_US.UTF-8; export LANG

MODULEPATH=/usr/share/Modules/modulefiles:/etc/modulefiles; export MODULEPATH

LOADEDMODULES=; export LOADEDMODULES

HISTCONTROL=ignoredups; export HISTCONTROL

SHLVL=1; export SHLVL

HOME=/root; export HOME

LOGNAME=root; export LOGNAME

QTLIB=/usr/lib64/qt-3.3/lib; export QTLIB

CVS_RSH=ssh; export CVS_RSH

SSH_CONNECTION=143.166.167.124\ 53008\ 10.180.57.93\ 22; export SSH_CONNECTION

MODULESHOME=/usr/share/Modules; export MODULESHOME

LESSOPEN=\|/usr/bin/lesspipe.sh\ %s; export LESSOPEN

G_BROKEN_FILENAMES=1; export G_BROKEN_FILENAMES

module=\(\)\ {\ \ eval\ \`/usr/bin/modulecmd\ bash\ \$\*\`"

"}; export module

cd /root || {

echo 'Execution directory inaccessible' >&2

exit 1

}

${SHELL:-/bin/sh} << 'marcinDELIMITER145f56ce'

php /var/www/ipdb5.0/unattend/release.php

marcinDELIMITER145f56ce

Job 68 didn't.

約伯68沒有。

at -c 68

#!/bin/sh

# atrun uid=48 gid=48

# mail apache 1

umask 22

PATH=/sbin:/usr/sbin:/bin:/usr/bin; export PATH

RUNLEVEL=3; export RUNLEVEL

runlevel=3; export runlevel

PWD=/var/www/ipdb5.0/run; export PWD

LANGSH_SOURCED=1; export LANGSH_SOURCED

LANG=C; export LANG

PREVLEVEL=N; export PREVLEVEL

previous=N; export previous

CONSOLETYPE=vt; export CONSOLETYPE

SHLVL=4; export SHLVL

UPSTART_INSTANCE=; export UPSTART_INSTANCE

UPSTART_EVENTS=runlevel; export UPSTART_EVENTS

UPSTART_JOB=rc; export UPSTART_JOB

cd /var/www/ipdb5\.0/run || {

echo 'Execution directory inaccessible' >&2

exit 1

}

${SHELL:-/bin/sh} << 'marcinDELIMITER348f4254'

php /usr/bin/php /var/www/ipdb5.0/unattend/release.php

marcinDELIMITER348f4254

Don't know if you guys can devine any more out of this than I can, but I figured it wouldn't hurt to post to see.

不知道你們是否可以在這方面做出更多的努力,但我認為發帖看看也不會有什么壞處。

1 个解决方案

#1

3

Finally found the answer. It turns out you need three things to be true that I hadn't set before.

終於找到了答案。事實證明,你需要三件事,而我之前沒有設定過。

You need to have the absolute path to the program you're calling (php had to be /usr/bin/php) - Thanks mti2935.

你需要有你正在調用的程序的絕對路徑(php必須是/ usr / bin / php) - 謝謝mti2935。

You need to have a shell set up for your apache user. - Thanks for getting me started in this direction craniumonempty. The command I had to run was : sudo chsh -s /bin/bash username

您需要為apache用戶設置shell。 - 感謝讓我開始朝着這個方向開始。我必須運行的命令是:sudo chsh -s / bin / bash username

Lastly you have to have an at.allow file created with the www-data group and apache user in it. (Make sure there is NOT a at.deny file, as this will counteract the allow.).

最后,您必須使用www-data組和apache用戶創建一個at.allow文件。 (確保沒有at.deny文件,因為這會抵消允許。)。

Once all of these are set the at will run successfully from your webserver. Also, be sure to have the basics which I went over in the main post. Give read/write/execute to apache for the script you're running, make sure the script itself works without running it with at, and verify the at job is being created.

設置完所有這些后,at將從您的網絡服務器成功運行。另外,一定要掌握我在主帖中介紹的基礎知識。為您正在運行的腳本提供讀/寫/執行apache,確保腳本本身無需運行,然后運行at,並驗證是否正在創建at作業。

Thank you all for the assistance.

謝謝大家的幫助。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值