简体   繁体   English

Crontab没有管道到文件(LINUX)

[英]Crontab not piping to file (LINUX)

The cronjob does not pipe the output from another script to a file but it works I execute it (not same user, chmod for both files is set to 777). cronjob不会将另一个脚本的输出传递给文件,但它可以执行它(不是同一个用户,两个文件的chmod设置为777)。

#! /bin/sh

. /disk2/etc/env_cron
SUBJ="Test"
TEXT=/disk2/home/user/mailtxt
ADDR="mail@domain.com"

  echo -e `date` > $TEXT
  echo -e "1\n\n\nq" | menu >> $TEXT
  mutt -s "$SUBJ" -i $TEXT -- $ADDR < /dev/null

I want it to pipe "echo -e 1\\n\\n\\nq" to the script Menu and in turn get the output in a file. 我希望它将“echo -e 1 \\ n \\ n \\ nq”传递给脚本Menu,然后将输出输出到文件中。 The output from Menu will just be text. Menu的输出只是文本。

The problem (as suggested) was that the cronjob did not have the script 'menu' in it's path. 问题(如建议的那样)是cronjob在其路径中没有脚本'menu'。 Changing "menu" in the script to the absolute path fixed it. 将脚本中的“菜单”更改为固定它的绝对路径。

echo -e "1\n\n\nq" | /folder/folder/menu >> $TEXT

EDIT: Do not forget to set the correct permissions on the textfile if the cronjob is run by another user. 编辑:如果cronjob由另一个用户运行,请不要忘记在文本文件上设置正确的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM