Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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