Page 1 of 1

Cron problem

Posted: Mon Nov 02, 2020 12:20 pm
by farzin12
hi there, first of all thanks for your greate work

i'm using a bash script to create new user
code:

Code: Select all

#!/bin/bash
PATH=$PATH:$HOME/bin
PATH=$PATH:/usr/local/vesta/bin
v-add-user apiUser21 p@sSWorb [email protected]

if i run this code by sh [filename.sh] it'll work without any problem
but when running it through incron, the user wont be added to my users list only a folder with the name of user will be created on my "/" for example "/apiUser21" which is wrong, can anyone please help me ?
(my incron is working when i'm using linux base commands: rm, cp, mkdir, unzip...)

Re: Cron problem

Posted: Fri Apr 15, 2022 9:23 am
by bekzclz11
Cron jobs can fail for an infinite variety of reasons but at Cronitor we have observed common failure patterns that can provide a useful starting point for your debugging process. In the rest of this guide, we will dive into these common failures with suggestions and solutions.

If you're adding a new cron job and it is not working...

Schedule errors are easy to make
Cron job schedule expressions are quirky and difficult to write. If your job didn't run when you expected it to, the easiest thing to rule out is a mistake with the cron expression.

Cron has subtle environment differences
A common experience is to have a job that works flawlessly when run at the command line but fails whenever it's run by cron. When this happens, eliminate these common failures:

The command has an unresovable relative path like ../scripts. (Try an absolute path)
The job uses environment variables. (Cron does not load .bashrc and similar files)
The command uses advanced bash features (cron uses /bin/sh by default)
Tip:Our free software, CronitorCLI, includes a shell command to test run any job the way cron does.

There is a problem with permissions
Invalid permissions can cause your cron jobs to fail in at least 3 ways. This guide will cover them all.
If your cron job stopped working suddenly...

System resources have been depleted
The most stable cron job is no match for a disk that is full or an OS that can't spawn new threads. Check all the usual graphs to rule this out.

You've reached an inflection point
Cron jobs are often used for batch processing and other data-intensive tasks that can reveal the constraints of your stack. Jobs often work fine until your data size grows to a point where queries start timing-out or file transfers are too slow.

Infrastructure drift occurs
When app configuration and code changes are deployed it can be easy to overlook the cron jobs on each server. This causes infrastructure drift where hosts are retired or credentials change that break the forgotten cron jobs.

Jobs have begun to overlap themselves
Cron is a very simple scheduler that starts a job at the scheduled time, even if the previous invocation is still running. A small slow-down can lead to a pile-up of overlapped jobs sucking up available resources.

A bug has been introduced
Sometimes a failure has nothing to do with cron. It can be difficult to thoroughly test cron jobs in a development environment and a bug might exist only in production.





https://krnl.run
https://indigocard.ltd