SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have two daily cronjobs for SquidAnalyzer and Squid log rotation. I'd like to combine them, and I wonder what's the best solution for this.
Every day at 13:00 I'm running /usr/bin/squid-analyzer. This command parses /var/log/squid/access.log and generates a detailed report about web usage. On some machines with many clients, this command can run for several minutes.
Next thing I have to do is run another cronjob for /usr/sbin/squid -k rotate, to rotate Squid's log files. Again, on networks with many clients, /var/log/squid/access.log* can get quite huge, so rotating the logs is vital to keep things manageable.
What would be the syntax to execute one cronjob after another? Can I simply put the following in a cronjob?
That command will run the second half only if the first command succeeds. If, for some reason, squid-analyzer bombs out and throws an exit code other than 0 (0 means a successful exit without errors), your logs won't rotate. If you want both commands to run no matter what, you'd want to do one of the following: replace the && with a ; (semicolon), create a shell script with them either on separate lines (as Eric mentioned), or separate them into separate cron jobs (which could entail using logrotate as BratPit mentioned).
See crontab(1) - jobs can be made to depend on other jobs. I've never used this functionality, but I've run across it several times in the manual page and filed it away as something that could be useful at some point. Here we are. :-)
Thanks for your numerous answers, guys. For some reason, I've found out that SquidAnalyzer simply stopped working, and I have this problem to tackle first before giving the above suggestions a try.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.