What user runs cron?

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers What user runs cron?
# 1  
Old 05-22-2002
What user runs cron?

I have a command that is found in /usr/ud51/bin called stopudt which safely stops idle database users (let's writes finish, etc).

If I login as root and issue stopudt [PID] the process is stopped.
I put a script in cron to run it and it says stopudt not found.

/usr/ud51/bin is in root's PATH. What other 'user' PATH do I need to modify... Or is that PATH the problem at all?

Thanks for any help!
# 2  
Old 05-22-2002
IIRC, cron jobs run under the users logon.

What OS are you running and how did you enter the command into crontab?

The reason I ask is that on one of my OpenBSD systems I use the `crontab -e` command to edit the crontab associated with the user that I am logged on as. This entry is saved in the /var/cron/tabs sub-dir under the users name to be read and executed from the cron daemon.

It sounds like your cron job is not executing as root and since the /usr/ud51/bin is in the root's path (and chances are, not in any of the other users path) it is being reported as not found.
# 3  
Old 05-22-2002

If you could post part of your script, I think the problem is in there.

If you have ROOT, any script should run from there if it is in the PATH OR if you give the full path in cron or on the command line, which I always do to avoid problems with trojans and such.

I see that you have the PID number as well from the commandline "/usr/ud51/bin/stopudt. How do you capture that from a script?

Also, try creating a cron as that user. su - username then create a crontab as that user and execute it. See what you get from that.

# 4  
Old 05-22-2002
Computer I run cron!

Originally posted by michieka
What user runs cron?
I'm user chenly, and I run cron. I schedule ftp updates, web page modifications, everything... ;-)
# 5  
Old 05-24-2002
Running AIX 4.33. This is the script. I had to put some environment variables in there, but simply putting the PATH probably would have worked as well. Using sed and awk to get the PID numbers from who -u...

# Logs users out that have been idle for 20 or more minutes.


export UDTBIN
export UDTHOME

/usr/ud51/bin/stopudt `who -u | sed -e "s/\./0/" -e "s/://g" | awk '$6 > 20 {print $7}'`
# 6  
Old 05-24-2002
Change default email for cron

How do I change who the default email goes to from cron jobs. I know it goes to the user by default. The man pages say I can use the mailto command, but I don't seem to have that on my system. AIX 4.33. How do you do it on yours?
# 7  
Old 05-24-2002
.forward email to root

You can redirect mail in a couple of ways. You can either use /etc/aliases for sendmail. or you can simply put a .forward in the user's home directory owned by root. Make the permissions 755.

/etc/aliases is a more efficient way to do it, but requires you to create a group and an alias name for the user. It works fine, but the simplest way is to use the .forward in that user home dir.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script runs manually, but not from cron

Hi, I "borrowed" a script I found online, to start a SAP router application on a Solaris 11 (SPARC) server. The script runs fine when calling it manually, but when I schedule it to run from cron, it doesn't. I don't see any warning or failure messages anywhere, just nothing happens. ... (11 Replies)
Discussion started by: bredman
11 Replies

2. Shell Programming and Scripting

Script runs in command-line fine but times out in CRON?

Hi, I have a script that seems to run to completion when in the command-line, but when it is run using the cron, it seems to time out. They both start and run fine, but on the CRON it stops prematurely. The script hits an API every few seconds and grabs data. Does anyone have any idea on... (4 Replies)
Discussion started by: phpchick
4 Replies

3. Shell Programming and Scripting

Odd results when my script runs from cron..

Hi folks, So I wrote a script to run "top", "awk" out values fro the "top" and send the results to a data file. I then set it to run in cron every 15 minutes. Now I'm noticing that the script, and it's sub-commands are not always cleanly finishing and, in my investigations, I am also... (11 Replies)
Discussion started by: Marc G
11 Replies

4. AIX

Script runs in shell but not cron

We run some menu driven software that has the ability to batch menu paths and generate reports quickly. Normally you run a batch like: $ BATCH BATCHNAME The batch program then prompts you for the date you want the report run for. I got some help from some folks on IRC to do the following: BATCH... (2 Replies)
Discussion started by: herot
2 Replies

5. UNIX for Dummies Questions & Answers

Script only runs as a particular user

Hi guys So I've got this PERL script that for one reason or another I need to run as a user other than the user that created the script. When I su - to another user the script won't run and doesn't give me any output as to why. No permission denied or anything like that. I've chmod 777'd the... (5 Replies)
Discussion started by: Jaymoney
5 Replies

6. Shell Programming and Scripting

Shell Script runs good manually but not through Cron tab

Hello Every one, I have a shell script which is running fine manually, but its giving me hard time when running tru cron job. :wall:. Am using #!/usr/bin/ksh >echo $SHELL /usr/bin/ksh Cron Job is as below, it execues but dosent do what i want it to do. 47 15 * * *... (1 Reply)
Discussion started by: naren.chowdhary
1 Replies

7. Shell Programming and Scripting

CRON shell script only runs correctly on command line

Hi, I'm new to these forums, and I'm hoping that someone can solve this problem... To make things short: I have DD-wrt set up on a router. I'm trying to run a script in CRON that fetches the daily password from my database using SSH. CRON is set like so(in web interface): * * * *... (4 Replies)
Discussion started by: louieaw
4 Replies

8. Shell Programming and Scripting

Script runs fine, but not in a cron

Okay, I have the following script that runs fine from a command line as well as an executable .sh file. It just moves any file/folder with movie* in the name to a folder called _Movies. The issue I'm running into is when it's call from a cron. find /mnt/HD_a2/BT/complete -iname "movie.*" -exec... (4 Replies)
Discussion started by: sammyk
4 Replies

9. Solaris

SFTP errorcode 1 when run on cron but runs manually

I am trying to run a sript on cron to SFTP data to a company. Private and public keys are set up. When I run this manully it works fine, however it was failing when run on cron. I have narrowed down the problem - it fails at the code that says if the error code is 0 then continue . . . I... (2 Replies)
Discussion started by: Heidi.Ebbs
2 Replies

10. UNIX for Advanced & Expert Users

Old cron entry still runs, but shouldnt

Hello, I'm running OSF1 V4.0 alpha. We used to have a job running from the cron at 6am everyday. We have removed the job from the crontab file, but the job still runs at 6am everyday. The job was in the root's crontab file. I cant figure out why this job is still running after we removed it... (3 Replies)
Discussion started by: xadamz23
3 Replies
Login or Register to Ask a Question