Solved

cronjobs not working via user - but works fine with root

Posted on 2013-10-29
12
324 Views
Last Modified: 2014-01-28
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
Comment
Question by:apunkabollywood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 6

Expert Comment

by:Kailash Aghera
ID: 39608456
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
 

Author Comment

by:apunkabollywood
ID: 39608658
Hi,

its  user:group  and 777
0
 

Author Comment

by:apunkabollywood
ID: 39608665
The problem when i am logging with user and scheduling any cronjob even echo command its not working
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 13

Assisted Solution

by:Daniel Helgenberger
Daniel Helgenberger earned 500 total points
ID: 39609156
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
 

Author Comment

by:apunkabollywood
ID: 39609312
I have checked secure logs and found this :
 pam_unix(crond:account): account myuser has expired (failed to change password)
 how to fix
0
 
LVL 13

Expert Comment

by:Daniel Helgenberger
ID: 39609329
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
 

Author Comment

by:apunkabollywood
ID: 39609393
Thanks Helge00 - it works - but why its necessary to give password - cant we run a cron job from a password less user?
0
 
LVL 13

Accepted Solution

by:
Daniel Helgenberger earned 500 total points
ID: 39609489
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
 

Expert Comment

by:shijub
ID: 39622058
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
 
LVL 13

Expert Comment

by:Sandy
ID: 39788148
chage -l user
0
 

Expert Comment

by:shijub
ID: 39790254
user name should be in cron.allow file to enable cron for users.
0
 

Author Closing Comment

by:apunkabollywood
ID: 39814371
Thank you :) its worked
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Noteā€¦
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question