cronjobs not working via user - but works fine with root

Hi,

Please help as cron jobs runs fine from root.

but when running from a specific users its not running.

Please help


no error and output or message coming.
apunkabollywoodAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Daniel HelgenbergerConnect With a Mentor Commented:
Good question; might be a bug in PAM... anyway; you should not have passwordless users. If you need a job run by a particular user, use roots crontab (either /etc/crontab or a script in /etc/cron.*) with the runuser command:
runuser -u myuser myscript.sh

Open in new window

Note, this is particularly handy with the -m switch; thus preserving root's environment variables.
0
 
Kailash AgheraCommented:
What is the ownership of the file which you are executing via cron? Make sure that it is user:user and the permission of the file is 755.
0
 
apunkabollywoodAuthor Commented:
Hi,

its  user:group  and 777
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
apunkabollywoodAuthor Commented:
The problem when i am logging with user and scheduling any cronjob even echo command its not working
0
 
Daniel HelgenbergerConnect With a Mentor Commented:
This is most commonly a run environment issue.
First, check whatever cron really runs your user's crontab entries:
grep CRON /var/log/syslog

Open in new window

If they are run, you most commonly have permissions/or $PATH errors. Please debug this with output redirection; like this example crontab entry:
crontab -l
0 0 * * * ~/myscript > ~/myscript.log 2>&1

Open in new window

Please note, commands like echo will never work (as expected to the console) with cron; the output is redirected to mails by default.
0
 
apunkabollywoodAuthor Commented:
I have checked secure logs and found this :
 pam_unix(crond:account): account myuser has expired (failed to change password)
 how to fix
0
 
Daniel HelgenbergerCommented:
This particular user, is it a local account or some AD / NIS account?

If local, you can set the password with:
sudo passwd myuser

Open in new window

0
 
apunkabollywoodAuthor Commented:
Thanks Helge00 - it works - but why its necessary to give password - cant we run a cron job from a password less user?
0
 
shijubCommented:
you can try disable password ageing for myuser account as below

chage  -m 0 -M -1 -I -1 -E -1 myuser

then do check with

chage -l myuser
0
 
SandyCommented:
chage -l user
0
 
shijubCommented:
user name should be in cron.allow file to enable cron for users.
0
 
apunkabollywoodAuthor Commented:
Thank you :) its worked
0
All Courses

From novice to tech pro — start learning today.