Hi @sunny_gvp ,
The issue occurs because cron environments lack interactive authentication and proper path/context. Here's exactly how to fix it.
1. Use a Service Account for Headless Authentication
The AIO CLI by default uses an interactive login (aio auth login) that doesn't persist for cron/scheduled jobs.
Instead, use Service Credentials (JWT or OAuth).
Steps:
- Go to Adobe Developer Console.
- Create or access your project > add Cloud Manager API.
- Add Service Account (JWT) credentials.
- Download the config.json with credentials.
Authenticate via AIO CLI (one-time setup):
aio auth:jwt:login --client-id <CLIENT_ID> --client-secret <CLIENT_SECRET> --technical-account-id <TECH_ID> --org-id <ORG_ID> --private-key-path /absolute/path/to/private.key --meta-scopes ent_cloudmgr_sdk
You can now use this service account in scripts without requiring manual login.
2. Set Required ENV Variables for Cron
Export required variables in your cron script:
export AIO_CLI_AUTH_CONTEXT=your-context
export AIO_CLI_CONFIG_DIR=/absolute/path/to/.aio
This ensures cron knows where to find your AIO auth context.
3. Use Absolute Paths in Cron
Avoid relative paths. Your script should use absolute paths to avoid failures like:
aio cloudmanager:logs:list <params> > /var/log/aio/log-download.log 2>&1
4. Add Logging in Your Cron Script
Wrap your command in a shell script (e.g., aio-download.sh) with logging:
#!/bin/bash
export AIO_CLI_AUTH_CONTEXT=your-context
export AIO_CLI_CONFIG_DIR=/home/ubuntu/.aio
/usr/local/bin/aio cloudmanager:logs:download --programId <PID> --environmentId <EID> --service author --logname access.log --output /home/ubuntu/logs >> /home/ubuntu/logs/aio-download.log 2>&1
And add this to cron:
0 3 * * * /home/ubuntu/aio-download.sh
5. Ensure AIO CLI and Node Are in Cron’s PATH
Sometimes cron doesn't inherit your full shell environment.
Add this at the top of your script:
export PATH=/usr/local/bin:/usr/bin:/bin
Regards,
Amit