Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

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.
0
apunkabollywood
Asked:
apunkabollywood
  • 5
  • 3
  • 2
  • +2
2 Solutions
 
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
 
apunkabollywoodAuthor Commented:
The problem when i am logging with user and scheduling any cronjob even echo command its not working
0
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

 
Daniel HelgenbergerCommented:
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
 
Daniel HelgenbergerCommented:
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

  • 5
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now