- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- cron question about multiple commands
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
тАО12-15-2004 03:27 AM
тАО12-15-2004 03:27 AM
we are using fbackup to backup our data to tape. We find its logging insufficient so we want to read the tape afterwards and create a file which contains the names of everything on the tape.
Is this a good way:
45 18 * * 1-4 /etc/fbackup -c /ses/backup_config -0 -g /ses/daily_backup -V/tmp/cron/backup_result -f/dev/rmt/0m ; /etc/frecover -I /tmp/cron/backup_result_index ; mt offl
45 18 * * 5 /etc/fbackup -c /ses/backup_config -0 -i/ -V/tmp/cron/backup_result -f/dev/rmt/0m ; /etc/frecover -I /tmp/cron/backup_result_index ; mt offl
The question I have is: will the commands after the ";" be executed ONLY when the previous command has completed?
Maybe a simple question, but I need to be sure.
TIA,
Jeroen.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2004 03:30 AM
тАО12-15-2004 03:30 AM
Re: cron question about multiple commands
Normally any command after ";" is supposted to run after the previous command has completed.
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2004 03:31 AM
тАО12-15-2004 03:31 AM
Re: cron question about multiple commands
Yes, that's true.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2004 03:32 AM
тАО12-15-2004 03:32 AM
Solution# date ; sleep 30 ; date
The above would display the date, sleep 30 seconds and display the date again.
Note that the commands would be executed no matter what. This means that is the first command fails, the next will be executed anyway.
If you want the execution of the 2nd command to be based on the successful (return code of 0) execution of the first, use a && separator.
# date && sleep 2 && date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2004 03:33 AM
тАО12-15-2004 03:33 AM
Re: cron question about multiple commands
"echo && ls" will execute ls only if echo exit code is 0.
Maybe you should do a script. Complex lines in crontab make it not clear and harder to maintain.
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2004 03:35 AM
тАО12-15-2004 03:35 AM
Re: cron question about multiple commands
Just a thought.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2004 03:37 AM
тАО12-15-2004 03:37 AM
Re: cron question about multiple commands
it will start after the preceding command has finished for good or bad. If you want to garuantee that the next command runns only in case of successful completion then use && as delimiter. see man sh-bourne
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2004 03:45 AM
тАО12-15-2004 03:45 AM
Re: cron question about multiple commands
Ummm, several commands together - why not put them in a script? Test the outcome of each previous command (using either $? or capture the standard output and check for error messages) before executing the next one?
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-16-2004 05:04 AM
тАО12-16-2004 05:04 AM
Re: cron question about multiple commands
#commandA ; commandB
will run them in sequence.
A matter of style: I'd put the commands in a script and call the script from cron - here's mine:
15 23 * * 5 /var/adm/fbackupfiles/backup.users.cart
Here's the guts of the script (runs in ksh):
fbackup -f $CART -0u \
-g ${FBDIR}/Graphs/graph.FullUsers \
-V ${FBDIR}/Headers/U$(date "+%y%m%d") \
-c ${FBDIR}/config \
-I ${FBDIR}/Indices/users.$(date "+%y%m%d")
ERRN=$?
if [ $ERRN = 0 ]
then
mailx -s "Weekly users backup done" $SYSMAIL << EOF
EOF
else
mailx -s "Weekly backup failed" $SYSMAIL < /dev/null
fi
Whenever I forget to put a tape in the drive, I get message #2
If there's a concern that the backup might complete and the tape is still bad, your plan is good (do an actual frecover).
Recently, though, I've had a backup tape with an end-of-reel problem - it "wouldn't sync". Last year I made 2 separate backups of all the filesystems. This year neither of the tapes I needed were good. (But it might be the drives.)
In that case, I'd probably get a good Index file off the tape and still not be able to recover.
For archival (doomsday) backups I'm going to ftp the files to a machine where I have a CD writer (a Dell PC) and put them on CD. (If I ever get to 11.x things might be easier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-17-2004 02:07 AM
тАО12-17-2004 02:07 AM
Re: cron question about multiple commands
thanks for the massive replies!
Jeroen.