Solved

cronjobs not working via user - but works fine with root

Posted on 2013-10-29
12
306 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
Comment Utility
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
Comment Utility
Hi,

its  user:group  and 777
0
 

Author Comment

by:apunkabollywood
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:apunkabollywood
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
chage -l user
0
 

Expert Comment

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

Author Closing Comment

by:apunkabollywood
Comment Utility
Thank you :) its worked
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

762 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

6 Experts available now in Live!

Get 1:1 Help Now