When editing a job, only the actual command entered is shown by default - the full command can be displayed using a new link.
---- Changes since 1.490 ----
Added action logging for scheduled commands created and deleted using this module.
+---- Changes since 1.500 ----
+Added an option to send email on command completion.
-d $in{'dir'} || &error($text{'create_edir'});
# Create the job
-&create_atjob($in{'user'}, $date, $in{'cmd'}, $in{'dir'});
+&create_atjob($in{'user'}, $date, $in{'cmd'}, $in{'dir'}, $in{'mail'});
&webmin_log("create", "job", $in{'user'}, \%in);
&redirect("");
return @rv;
}
-# create_atjob(user, time, commands, directory)
+# create_atjob(user, time, commands, directory, send-mail)
sub create_atjob
{
local @tm = localtime($_[1]);
local $date = sprintf "%2.2d:%2.2d %d.%d.%d",
$tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900;
-local $cmd = "cd ".quotemeta($_[3])." ; at $date";
+local $mailflag = $_[4] ? "-m" : "";
+local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
local @uinfo = getpwnam($_[0]);
if ($uinfo[2] != $<) {
# Only SU if we are not already the user
print &ui_table_row($text{'index_cmd'},
&ui_textarea("cmd", $in{'ext_cmd'}, 5, 50));
+# Send email on completion
+print &ui_table_row($text{'index_mail'},
+ &ui_yesno_radio("mail", 0));
+
print &ui_table_end();
print &ui_form_end([ [ undef, $text{'create'} ] ]);
return @rv;
}
-# create_atjob(user, time, commands, directory)
+# create_atjob(user, time, commands, directory, send-mail)
sub create_atjob
{
local @tm = localtime($_[1]);
local $date = strftime "%H:%M %b %d", @tm;
-local $cmd = "cd ".quotemeta($_[3])." ; at $date";
+local $mailflag = $_[4] ? "-m" : "";
+local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
local @uinfo = getpwnam($_[0]);
if ($uinfo[2] != $<) {
# Only SU if we are not already the user
index_date=Run on date
index_time=Run at time
index_cmd=Commands to execute
+index_mail=Send email on completion?
index_id=Job ID
index_exec=Run at
index_created=Created on
return @rv;
}
-# create_atjob(user, time, commands, directory)
+# create_atjob(user, time, commands, directory, send-email)
sub create_atjob
{
local @tm = localtime($_[1]);
local $date = sprintf "%2.2d:%2.2d %d.%d.%d",
$tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900;
-local $cmd = "cd ".quotemeta($_[3])." ; at $date";
+local $mailflag = $_[4] ? "-m" : "";
+local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
local @uinfo = getpwnam($_[0]);
if ($uinfo[2] != $<) {
# Only SU if we are not already the user
return @rv;
}
-# create_atjob(user, time, commands, directory)
+# create_atjob(user, time, commands, directory, send-email)
sub create_atjob
{
local @tm = localtime($_[1]);
local $date = sprintf "%2.2d:%2.2d %d.%d.%d",
$tm[2], $tm[1], $tm[3], $tm[4]+1, $tm[5]+1900;
-&open_execute_command(AT, "su \"$_[0]\" -c \"cd $_[3] ; at $date\" >/dev/null 2>&1", 0);
+local $mailflag = $_[4] ? "-m" : "";
+&open_execute_command(AT, "su \"$_[0]\" -c \"cd $_[3] ; at $mailflag $date\" >/dev/null 2>&1", 0);
print AT $_[2];
close(AT);
-&additional_log('exec', undef, "su \"$_[0]\" -c \"cd $_[3] ; at $date\"");
+&additional_log('exec', undef, "su \"$_[0]\" -c \"cd $_[3] ; at $mailflag $date\"");
}
# delete_atjob(id)
return @rv;
}
-# create_atjob(user, time, commands, directory)
+# create_atjob(user, time, commands, directory, send-email)
sub create_atjob
{
local @tm = localtime($_[1]);
local $date = strftime "%H:%M %b %d", @tm;
-local $cmd = "cd ".quotemeta($_[3])." ; at $date";
+local $mailflag = $_[4] ? "-m" : "";
+local $cmd = "cd ".quotemeta($_[3])." ; at $mailflag $date";
local @uinfo = getpwnam($_[0]);
if ($uinfo[2] != $<) {
# Only SU if we are not already the user