Solved

cronjobs not working via user - but works fine with root

Posted on 2013-10-29
12
311 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
  • 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
 
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LDAP find expired users 8 69
route 2 traffic streams on single NIC 6 34
Linux hostname change 2 51
Video Streaming 6 52
If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

947 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now