AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only
  • 1.  Scripting assistance

    Posted Thu July 21, 2022 01:00 PM
    Currently, I have to manually start/stop my applications with the scripts below.  I didn't write the scripts.  I want to write a script to automate the steps and be able to schedule it.  I have not written a script before and looking for some guideance.

    The manual scripts/commands used to shutdown are:
    log into server as root

    SU - APPUSER
    cd /Installed/Apps
    ./downapp 
    ./downtomcat.sh
    ./downsqlanywhere.sh
    SU - root
    I am prompted for the password
    Shutdown -Fr

    The applications startup when the server boots however, if I want to manually start the scripts are used:
    SU - APPUSER
    cd /Installed/Apps
    ./startsqlanywhere.sh
    ./starttomcat.sh
    ./startapp


    This is how I think the Shutdown Script for Application server would look based on my research.  The script would be scheduled and I assume it would run with root authority.  

    su appuser -c /Installed/Apps/downapp
    su appuser -c /Installed/Apps/downtomcat.sh
    su appuser -c /Installe/Apps/downsqlanywhere.sh
    Shutdown -Fr

    If I want the script in the scheduler, are there any specific attributes that need to be set? 
    When running in the scheduler, is it assumed that root is the user?
    Is there something missing from the script or is there a better way to create it?

    Thanks



    ------------------------------
    Michael Garczynski
    Director - SAP Architecture
    DAP Products
    ------------------------------


  • 2.  RE: Scripting assistance

    Posted Fri July 22, 2022 10:09 AM

    when you say "scheduler", are you talking about cron?  Or another product?
    I can't speak about other schedulers, but for cron, it can run as any user in the system.

    look in /var/spool/cron/crontabs (don't edit them directly)... use the crontab command

    your scripts look fine (if run by root).  Create those lines in a file, then chmod to ensure it's executable.



    ------------------------------
    Tom McGivern
    ------------------------------



  • 3.  RE: Scripting assistance

    Posted Tue July 26, 2022 07:58 AM
    Tom,
    Thank you for the review and the tips.  Yes, Cron is the scheduler I was talking about.  I am familiar with the crontab command and how to add a schedule entry.  I thought the script was correct, but having never written one, I wanted to check.

    ------------------------------
    Michael Garczynski
    Director - SAP Architecture
    DAP Products
    ------------------------------