- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Cron and posix programming
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
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
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
09-27-2000 06:36 AM
09-27-2000 06:36 AM
Cron and posix programming
Im trying to run a command and redirect it to a file.
The command does not matter but here is the problem Im having after redirection.
On the command line I can run "some_command > /tmp/temp_`date +%m%d`.log" and it works the way we want it, but it does not work running from cron. I know it has to be some environment variable but Im at a loss. The file when run from cron ends up cutting off after the underscore. Any help would be most appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2000 06:43 AM
09-27-2000 06:43 AM
Re: Cron and posix programming
One workaround is to get cron to call a script that itself calls
some_command > /tmp/temp_`date +%m%d`.log
If some_command is a script that you have control over then get it to redirect its standard output/error with:-
exec 1>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2000 06:50 AM
09-27-2000 06:50 AM
Re: Cron and posix programming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2000 06:58 AM
09-27-2000 06:58 AM
Re: Cron and posix programming
After trying the same thing myself and checking cron's log (/var/adm/cron/log) it appears that cron doesn't like the % characters.
If you escape them with backslash then it works eg
bdf > /tmp/test.`date +\%m\%d`.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2000 07:01 AM
09-27-2000 07:01 AM
Re: Cron and posix programming
#!/bin/ksh
COMMAND=$1
DDD=$(date +%m%d)
$1 >/tmp/temp_$DDD.log
in cron
time * * * script bdf
just a thought
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2000 07:04 AM
09-27-2000 07:04 AM
Re: Cron and posix programming
I found the answer I was looking for.
in cron it interprets % characters as new lines. Here is a excerpt from crontab(1m)
A percent character (%) in this field (unless
escaped by a backslash ()) is translated to a newline character,
dividing the field into "lines". Only the first "line" (up to a % or
end-of-line) of the command field is executed by the shell. Any other
"lines" are made available to the command as standard input.
so when I do the following in cron it works:
some_command > /tmp/temp_`date +%m%d`.log
you have to escape the % signs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2000 10:37 PM
09-27-2000 10:37 PM
Re: Cron and posix programming
33,03 * * * * xx=`date +%d`; date +"%D.%X" >>/var/adm/sa/vmstat.$xx