为非root用户创建crontab [英] Creating crontab for non-root user

查看:1137
本文介绍了为非root用户创建crontab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过crontab运行脚本,该脚本需要以 oracle 用户身份运行.我尝试通过以下方式为该用户创建一个crontab: su -u oracle crontab -e允许我创建一个.我编辑了文件以运行perl脚本:

I am attempting to run a script through crontab that is required to run as an oracle user. I have tried creating a crontab for that user by: su -u oracle crontab -e which has allowed me to create one. I edited the file to run a perl script:

0 5 * * * /usr/bin/perl /path/master.pl > /tmp/debug.log

但是,如果时间流逝,则什么也不会运行. 这是为非root用户创建crontab的正确方法吗?同样,master.pl文件调用多个脚本,如果这有所作为,则还需要以oracle用户身份完成多个脚本.

However when the time passes nothing is run. Is this the proper way to create a crontab for non-root user? Also the master.pl file call multiple scripts that also need to be done as a oracle user if that makes a difference.

推荐答案

使用crontab-u选项. 手册页说:

-u追加要修改crontab的用户名. 如果未使用此选项,则crontab会检查您的" crontab, 即执行命令的人的crontab.笔记 su(8)可能会使crontab感到困惑,因此在执行命令时 在su(8)下,您应该始终使用-u选项.如果不 crontab是为特定用户而存在的,它是为他创建的 第一次在其下使用crontab -u命令 用户名.

-u Appends the name of the user whose crontab is to be modified. If this option is not used, crontab examines "your" crontab, i.e., the crontab of the person executing the command. Note that su(8) may confuse crontab, thus, when executing commands under su(8) you should always use the -u option. If no crontab exists for a particular user, it is created for him the first time the crontab -u command is used under his username.

因此正确的命令是:

sudo crontab -e -u oracle

这篇关于为非root用户创建crontab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆