pub struct CronJob {Show 16 fields
pub id: String,
pub name: String,
pub schedule: String,
pub command: String,
pub job_type: JobType,
pub agent_config: Option<AgentJobConfig>,
pub status: JobStatus,
pub timeout_ms: u64,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub last_run: Option<DateTime<Utc>>,
pub next_run: Option<DateTime<Utc>>,
pub run_count: u64,
pub fail_count: u64,
pub working_dir: Option<String>,
pub env: Vec<(String, String)>,
}Expand description
A cron job definition
Fields§
§id: StringUnique job identifier
name: StringHuman-readable job name
schedule: StringCron schedule expression (5 fields: min hour day month weekday)
command: StringCommand to execute (shell command or agent prompt, depending on job_type)
job_type: JobTypeJob type: shell (default) or agent
agent_config: Option<AgentJobConfig>Agent configuration (required when job_type is Agent)
status: JobStatusCurrent job status
timeout_ms: u64Execution timeout in milliseconds (default: 60000)
created_at: DateTime<Utc>Creation timestamp
updated_at: DateTime<Utc>Last update timestamp
last_run: Option<DateTime<Utc>>Last execution timestamp
next_run: Option<DateTime<Utc>>Next scheduled run timestamp
run_count: u64Total successful run count
fail_count: u64Total failed run count
working_dir: Option<String>Working directory for command execution
env: Vec<(String, String)>Environment variables for command execution
Implementations§
Source§impl CronJob
impl CronJob
Sourcepub fn new(
name: impl Into<String>,
schedule: impl Into<String>,
command: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, schedule: impl Into<String>, command: impl Into<String>, ) -> Self
Create a new cron job
Sourcepub fn with_timeout(self, timeout_ms: u64) -> Self
pub fn with_timeout(self, timeout_ms: u64) -> Self
Set the timeout in milliseconds
Sourcepub fn with_working_dir(self, dir: impl Into<String>) -> Self
pub fn with_working_dir(self, dir: impl Into<String>) -> Self
Set the working directory
Sourcepub fn with_env(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn with_env(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add an environment variable
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the job is running
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CronJob
impl<'de> Deserialize<'de> for CronJob
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CronJob
impl RefUnwindSafe for CronJob
impl Send for CronJob
impl Sync for CronJob
impl Unpin for CronJob
impl UnsafeUnpin for CronJob
impl UnwindSafe for CronJob
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more