- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: cron Entry not working
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2010 04:31 AM
тАО04-27-2010 04:31 AM
cron Entry not working
I'm facing problem in crontab entry execution
1. I have a .sh script in /tmp/bdf/fs.sh
2. this script is running fine by manual ( #sh fs.sh )
3.Edited crontab -e and put entry like
0 11 * * * /tmp/bdf/fs.sh ( everyday 11am )
4. file permission is ok
-rwxrwxrwx 1 root sys 2077 Apr 23 11:54 fs.sh
but this cron job not running
cron log
>>>> > CMD: /tmp/bdf/fs.sh
syslog
>> : Accepted publickey for root from x.x.x.x
in var/mail/root
Message-Id: <201004270530.o3R5UAMx020211@fqdn.com>
Subject: cron
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
pls give me the solution ,
Thanks & Regards,
Kalai.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2010 04:36 AM
тАО04-27-2010 04:36 AM
Re: cron Entry not working
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2010 04:36 AM
тАО04-27-2010 04:36 AM
Re: cron Entry not working
Most likely cause is missing environmental variables like PATH in your script, if you add the PATH of all your commands in the beginning of the script, it will run.
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2010 08:13 AM
тАО04-27-2010 08:13 AM
Re: cron Entry not working
Not a good place to store anything permanent. Any user can erase this file or rename it.
>> 2. this script is running fine by manual ( #sh fs.sh )
...as mentioned, it runs from your login. Type the command env and you will see that there are a lot of variables defined because you logged in. cron does not login.
>> 3.Edited crontab -e and put entry like
0 11 * * * /tmp/bdf/fs.sh ( everyday 11am )
OK
>> 4. file permission is ok
-rwxrwxrwx 1 root sys 2077 Apr 23 11:54 fs.sh
but this cron job not running
File permission is *NOT* OK. -rwxrwxrwx is the worst possible permission to set for any script, especially a script to be run by root. It should be -rwx------ (chmod 700 /tmp/bdf/fs.sh) so that the contents of the script is protected. This setting will not fix your problem but at least it will keep the script from being trashed by another user.
Your script apparently has no status or error checking internally so to see what is wrong, you will need to trace the script from cron. To do this, add the line:
set -x
after your interpreter line in your script (after the first line which says #!/usr/bin/sh). You do have an interpreter line as line 1, correct?
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2010 04:37 AM
тАО04-28-2010 04:37 AM
Re: cron Entry not working
Hi Bill Hassell,
My responses in-line below
1.Not a good place to store anything permanent. Any user can erase this file or rename it.
>>>this is test server so users already know root passwd , so that ok
2....as mentioned, it runs from your login. Type the command env and you will see that there are a lot of variables defined because you logged in. cron does not login
>> I'm logging as a super user ( root user )
3. OK
4.ok file premission changed ( 700 )
>> -rwx------ 1 root sys 2082 Apr 22 18:20 fs.sh
set -x --> where i need to add , pls find the attached my script ,
This is script is running fine my manual
{ #cd /tmp/bdf
# sh fs.sh
} --> working fine , and get output as FSusage_27-Apr.txt file
by using cron is not working , pls help how to resolve this issues ,
Thanks , Kalai.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2010 04:53 AM
тАО04-28-2010 04:53 AM
Re: cron Entry not working
I have tested your script and I've seen it works, but I had to manually enter the user/passwd when it connects to the hosts...
You might provide the user/passwd data to not be prompted for them.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2010 05:01 AM
тАО04-28-2010 05:01 AM
Re: cron Entry not working
"cron supplies a default environment for every shell, defining:
HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh"
When you run the script manually, your own environment has many more variables set and a much more extensive PATH variable. Perhaps the easiest way to provide that sort of environment to your script would be to invoke your profile in the script, like this:
. ~/.profile
Make that the very first line of your script. You may want to substitute /etc/profile in place of .profile depending on how your system is set up to define environment variables.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2010 05:03 AM
тАО04-28-2010 05:03 AM
Re: cron Entry not working
>set -x --> where i need to add
As Bill said:
The first line of your script should be:
#!/usr/bin/sh
The second:
set -x
Your sixth line:
rm FSusa* - Add the full path of all files!
Now you should get error messages with more informations, which you need.
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2010 11:22 PM
тАО04-28-2010 11:22 PM
Re: cron Entry not working
>> we need to generate rsa and
do >> cat .ssh/id_rsa.pub |ssh second_hostname 'cat >> .ssh/authorized_keys'
after that only first time will ask password
Hi V. Nyga
>> after added as you said still same response
not running cron job ,
Hi Pete Randall ,
>> pls I'm not getting you ,, i have already attached my script , can you help
Thanks in advance , Kalai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2010 11:57 PM
тАО04-28-2010 11:57 PM
Re: cron Entry not working
As Volkmar said, you need to insert at the top of your script:
#!/usr/bin/sh
set -x
Then run this with cron and then attach your mail message.
Ah, you can't do this:
function CHECK_DISK_USAGE {
echo
This echo tells cron you are a bad guy and deserve a mail message.