Reputation: 1
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
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.
Upvotes: 0
Views: 2644
Reputation: 33638
Use crontab
's -u
option. The man page says:
-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.
So the correct command is:
sudo crontab -e -u oracle
Upvotes: 2