- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Can't run a simple script in crontab job
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
Forums
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
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
тАО06-14-2007 10:40 PM
тАО06-14-2007 10:40 PM
Can't run a simple script in crontab job
#vi /tmp/test_script
pwd > /tmp/path.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2007 11:03 PM
тАО06-14-2007 11:03 PM
Re: Can't run a simple script in crontab job
When running through crontab, the environment is not set (as opposed to you running the script from your shell).
The 1st line of your script should be:
#!/bin/sh
And you might want to replace 'pwd' with '/bin/pwd' or copy the 'PATH' line from your profile and make it the 2nd line of your script.
Cheers,
Wout
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2007 11:14 PM
тАО06-14-2007 11:14 PM
Re: Can't run a simple script in crontab job
But I think that even the script has problem , it still will run , but I found that it didn't run ( I have checked log ) , can advise what is the problem ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2007 11:21 PM
тАО06-14-2007 11:21 PM
Re: Can't run a simple script in crontab job
how did you schedule the job - and is the cron daemon running?
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2007 11:31 PM
тАО06-14-2007 11:31 PM
Re: Can't run a simple script in crontab job
the other cron job is normal to run , but only this job not run .
The crontab is as below.
30 16 * * * /tmp/test_script , it is very standand setting, I sure the setting is correct.
thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2007 11:34 PM
тАО06-14-2007 11:34 PM
Re: Can't run a simple script in crontab job
1) The script needs a she-bang line at the top (e.g. #!/usr/bin/sh) and should exit at the bottom.
2) Ensure the name of the user whose crontab you added the script to appears in /var/adm/cron/cron.allow.
3) Ensure the user designated to execute the script via cron has read/execute permission on the script as well as the directory hierarchy containing it.
4) Restart cron via '/sbin/init.d/cron stop && /sbin/init.d/cron start'.
5) In this instance, 'pwd' is in '/usr/bin', which is part of cron's default PATH. But if an executable appearing in the script to be executed by cron weren't in '/usr/bin' or '/usr/sbin', you would have to explicitly add its directory to the PATH.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2007 11:36 PM
тАО06-14-2007 11:36 PM
Re: Can't run a simple script in crontab job
maybe the problem is: what should the 'working directory' be, when running this script through cron?
Test with 'cd /tmp' then 'pwd'
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2007 11:39 PM
тАО06-14-2007 11:39 PM
Re: Can't run a simple script in crontab job
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2007 11:40 PM
тАО06-14-2007 11:40 PM
Re: Can't run a simple script in crontab job
Hi,
please post the output of the following commands
whoami
ll /tmp/test_script
crontab -l | grep test_script
ps -ef | grep cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-15-2007 04:39 PM
тАО06-15-2007 04:39 PM
Re: Can't run a simple script in crontab job
I assume that was /var/adm/cron/log ?
>PCS: 5) In this instance, 'pwd' is in /usr/bin, which is part of cron's default PATH.
Actually pwd is a shell builtin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-15-2007 06:00 PM
тАО06-15-2007 06:00 PM
Re: Can't run a simple script in crontab job
pwd > /tmp/path.txt
Can you also include date command just before the pwd so that you would be able to see whether it is run or not.
#vi /tmp/test_script
/bin/date >> /tmp/path.txt
/bin/pwd >> /tmp/path.txt
chmod 744 /tmp/test_script
and test it. Also check the /var/adm/cron/log file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-15-2007 10:50 PM
тАО06-15-2007 10:50 PM
Re: Can't run a simple script in crontab job
Can you try the following and upload the content of the generated files:
30 16 * * * /tmp/test_script 1>/tmp/output.crn 2>/tmp/error.crn
revert
kind regards
yogeeraj