in reply to Re: use lib "."
in thread use lib "."

I do find it slightly odd that you have scripts in your lib dir. I tend to keep all my cron jobs in a cron dir for clarity.

On sites where I have more than one cron script I keep them in a scripts directory.

In this case, all the modules have their own directories and this is the only script outside of the www directory. So it is the only thing in the lib directory other than more directories.

Would you still use a cron directory even if you can be pretty sure there will only ever be this one script?

You can have the same shell script (or 2 copies of the same script) for both test and prod

No need - only production has the cron maintenance script...

Replies are listed 'Best First'.
Re^3: use lib "."
by hippo (Archbishop) on Aug 12, 2023 at 22:55 UTC
    Would you still use a cron directory even if you can be pretty sure there will only ever be this one script?

    I would, yes. The only things I expect to see in the lib tree should be modules or POD files.


    🦛

      I would, yes

      Thanks hippo - on the advice of yourself and kcott my structure is getting changed as things are updated...

      On a similar topic, traditionally any cron tasks I had called the web script for that functionality which detected if it was running under cron or CGI by checking the $ENV{'DEFAULT_GATEWAY'} variable. More recently I have created separate scripts for each function that needs to run on cron.

      However, unless there is a different schedule, I am now grouping all that into one script.

      For example, I have a script that runs every morning that sends out emails on some days to users who have unread notifications and also sends emails to admins on other days to tell them about blogs that need reviewing. Plus, it does some daily tidying. Would you have a single script to deal with all the daily activities or multiple scripts?

        If the email work is similar enough (for "users who have unread notifications and also sends emails to admins on other days to tell them about blogs that need reviewing"), then keep that in a script. Or, have separate modules|functions in a package to do the emailing & create shorter, specific programs to use those modules.

        The "daily tidying" seems like should be separate task, in- or outside of cron.