sábado, 23 de novembro de 2024
Home
Artigos
Banco de Dados
Access
Firebird
Microsoft SQL Server
MySql
Oracle
Sybase
BI
QlikView
Dicas de Internet
e-business
Hardware
Multimídia
Flash
Programação
.NET/ASP.NET
.NET/C#
.NET/Framework
.NET/VB.NET
ASP
C/C++
Clipper
Cobol
CSS
Delphi
Java
Javascript
JSP
Palm
Perl
PHP
Shell
Visual Basic
WAP
Redes
Segurança
Servidores E-mail
Servidores Web
Apache
Microsoft IIS
Sistemas Operacionais
AIX
DOS
HPUX
Linux
Palm OS
Solaris
True64
Windows 7
Windows 9X
Windows NT
Windows Vista
Windows XP
Software Review
PC
Storages
Veritas VM
Conteúdo atual do site:
[807] ítens, entre artigos, funções e documentos.
Pesquisa Rápida:
Últimos 3 acessos:
Alexandre Neves 03/03/2015 11:08:01 167 acesso(s) alexandre neves 03/03/2015 11:06:42 1 acesso(s) Marcelo Torres 21/01/2015 15:24:53 61 acesso(s)
Opções:
Listagem completa Listagem simples
Ranking Colaboradores:
Adenilton Rodrigues - [304] Alexandre Neves - [61] Douglas Freire - [54] Marcelo Giovanni - [53] Marcelo Torres - [43] Angelita Bernardes - [31] Addy Magalhães Cunha - [28] Manuel Fraguas - [24] Ludmila Valadares - [20] Marcelo Capelo - [18]
Utilize o AT para executar comandos em horários pré-determinados e/ou repetitivos em seu sistema - Similar ao cron do Linux
Inicialmente, para que o comando AT funcione é necessário que o serviço Schedule esteja ativo e rodando. Adicionando um agendamento usando o AT A sintaxe é a seguinte: at [\\\\computername] time [/interactive] [/every:date[,...] 0x7C /next:date[,...]] "command" Parametros: NOTA: Se o AT for usado sem nenhum parametro então será lhe apresentado a lista atual dos agendamentos. \\\\computername - Especifica o nome do computador remoto. Se este parâmetro for omitido então será programado o computador local. time - Especifica o horário de execução. No seguinte formato: hours:minutes in 24-hour notation (00:00 [midnight] through 23:59). /interactive - Permite interação do Job com o usuário através do desktop na hora em que o comando estiver sendo executado. /every:date[,...] - Executa o comando nos dias especificados, por exemplo: /every Thursday ou /every:M,T,W,Th,F,S,Su (Todos os dias da semana) Monday = m Tuesday = t Wednesday = w Thursday = th Friday = f Saturday = s Sunday = su Ou 1 ou mais dias do mês (Usando números de 1 a 31) Separe várias datas usando ', se a data for omitida então o dia e mês corrente serão assumidos. /next:date[,...] - Similar ao /every "command" - Poderá ser um comando do Windows, um programa (.EXE ou .COM) ou ainda (.BAT ou .CMD). Manutenção dos serviços agendados: at [\\\\computername] [[id] [/delete [/yes]] \\\\computername - Especifica o nome do computador remoto. Se este parâmetro for omitido então será programado o computador local. id - Identificador numérico do agendamento. /delete - Cancela agendamento específico. Se omitido, todos agendamentos serão excluidos. /yes - Força YES para todas perguntas de deleção de agendamentos. Visualizando resultados: O comando agendado através do AT roda num processo em background, assim nenhuma mensagem é apresentada na tela do computador onde está sendo executado. Para redirecionar a saida utilize o símbolo (>). Se você redirecionar a saída então coloque o comando entre aspas. O diretório padrão de execução é o %systemroot%. Para ativar ou adicionar o comando AT você deverá ser membro do grupo de administradores locais. O command não é automaticamente carregado, o código é interpretado. Assim, se desejar rodar um comando que não seja .EXE deverá explicitar o CMD.EXE antes, por exemplo: cmd /c dir > c:\\saida.txt Trocando a hora do sistema: Se você mudar o horário do sistema depois de ter realizado algum agendamento sincronize e revise os agendamentos executando o AT sem nenhum parametro. Guardando os agendamentos: Os agendamentos são armazenados no registry, assim não são perdidos quando você reinicia o serviço Schedule. Mais informações, em inglês: Schedule a batch file to run on a computer at a specific date and time. syntax Create an AT job: AT [\\\\computername] hh:mm [/INTERACTIVE] [ /EVERY:day(s) | /NEXT:day(s) ] "command" Delete an AT job: AT [\\\\computername] [ [id] [/DELETE] | /DELETE [/YES]] key \\\\computername : Execute the AT command on a remote computer. id : An id number AT assigns to each scheduled job. /delete : Cancel a scheduled job. If id is omitted, all jobs are deleted. /yes : Use with /delete to supress the confirmation message. hh:mm : The time to run the command. /interactive : Allow the job to interact with the desktop of the current user when the job runs. /every:day(s) : Run the command every day(s) of the week or month. (default: dd=today) /next:day(s) : Run the command on the next occurrence of the day. (default: dd=today) "command" : The batch program or command to run. If the path to this includes spaces, put double quotation marks around the path. "C:\\Program Files\\My Batch.cmd" Day(s) are in this format: (English Locale EN) Monday = m Tuesday = t Wednesday = w Thursday = th Friday = f Saturday = s Sunday = su or a specific day of the month: e.g. 5th of every month = 5 Examples: Running a command every day AT_DAILY.cmd :::::::::::: AT 23:30 /EVERY:m,t,w,th,f,s,su c:\\backups\\every_day.cmd :::::::::::: Running a command every Friday AT_WEEKLY.cmd :::::::::::: AT 23:30 /EVERY:f c:\\backups\\weekly.cmd :::::::::::: Resetting the above AT commands RESET_AT_JOBS.cmd :::::::::::: AT /delete /yes CALL AT_DAILY CALL AT_WEEKLY :::::::::::: Running a command this evening (once only) AT_TODAY.cmd :::::::::::: AT 23:30 /NEXT: c:\\backups\\today.cmd :::::::::::: Rights needed to issue an AT command By default only an Administrator can issue an AT command, and a Domain Admin can direct the command at any machine. To configure an AT job as part of a users login script - the user must be a member of the local Administrators group. Be aware that a global workgroup setup with 'Local Administrator' rights would allow every member full control of not only their own workstation but EVERY workstation on the network. To setup a workstation so that anyone logging in will have local admin rights (to that machine only) use the command: NET LOCALGROUP "Administrators" INTERACTIVE /add or NET LOCALGROUP "Power Users" INTERACTIVE /add The "Schedule" service must be running to use the AT command. If you have Internet Explorer 5.0 or greater this is renamed as the "Task Scheduler" service. Task Scheduler has a bad reputation due to a security vulnerability it introduced - however this was fixed with IE 5.01 The "Schedule" service (ATSVC) rather than the "Task Scheduler" service must be running to use SOON with a delay of less than 60 seconds. - see Q237840 User Rights needed for the AT command to perform it's task The User Account under which the Schedule service runs may require specific file access permissions, user permissions and drive mappings. The User Account is selected under Control Panel, Services, SCHEDULER, Startup, Logon As... If you have Internet Explorer 4 or greater the User Account is selected under SCHEDULED TASKS, Advanced, AT Service Account. You also need to *stop* and restart the service before the change in UserAccount will take effect. Don't try to pass more than one command into AT, put everything you want to achieve in one batch file and then just call that batch file from AT. Here's how to check if a user account has sufficent rights for a particular task: AT hh:mm /interactive %comspec% /k Setting hh:mm for one minute from now will open a cmd window at the specified time. In this window you can check the following settings: The PATH Environment variables (particularly TEMP). Drive mappings - you can add these by putting appropriate NET USE... commands at the beginning of your batch file. Next, go ahead and run your batch file in this console window, note the errors, and fix them. Once the errors have been fixed, you can remove the /interactive switch and schedule the batch file with some confidence that it will work as intended. The Scheduled Tasks GUI Scheduled tasks are available with IE 4.0 + and extend the functionality of AT, particularly in the area of permissions. The Task Scheduler option adds an extra folder (and extra menu options) to Windows Explorer. Task Scheduler options are stored in the registry HKLM\\SOFTWARE\\Microsoft\\SchedulingAgent\See Q226370 for bugs related to the Task Scheduler. Also note that using the GUI to edit a Scheduled Task (as opposed to editing at the command line) you are required to supply the password for the user account under which the task will run. (In other words the task can no longer run under the system account) "We don't wake up for less than $10,000 a day" - Linda Evangelista Related commands: SOON - Schedule a command to run in the near future CALL - Call one batch program from another. JT - Win 2000 Task Scheduler Command Line Utility Equivalent Linux BASH commands: cron - Daemon to execute scheduled commands crontab - Schedule a command to run at a later time watch - Execute/display a program periodically Connecting to Network Drives: Scheduled jobs that access the network should not use redirect drives made by the user. The Schedule service may not be able to access these drives and they may not be present if a different user is logged on at the time the scheduled job runs. Instead, scheduled jobs should use UNC paths. For example, at 1:00pm my_backup \\\\server\\share and not at 1:00pm my_backup x: where x: is a connection made by the user. If you schedule at command that uses a drive letter to connect to a shared directory, you should not include at command to disconnect the drive when you are finished using it. If the drive is not disconnected, the drive letter assigned will not be available or seen at the command prompt. Example of configuring hdindex.bat The following is an example of the at command being scheduled for the HelpDesk Expert Product: at \\\\pad 00:00 /every:M,T,W,Th,F,S,Su C:\\WINNT\\system32\\cmd.exe /c c:\\helpdesk\\client\\bin\\hdindex.bat This example would export the database everyday at midnight on a machine named pad. Para finalizar, outro exemplo: cria_agenda.bat ------- @echo off Rem Esquema de agendamento :Begin at 06:00 /every:M,T,W,Th,F,S,Su c:\\util\\importa.bat :End Quebra-Linha Colaborador..: Alexandre Neves Categoria(s).: Windows NT; Versão.......: 1.0 Data.........: 26/02/2003 21:00:30 Visualizado..: 9431 vezes Fonte........: Internet
Alexandre Neves
Últimos Artigos deste colaborador Alterando a porta padrão do TS (3389) - 12/05/2010 10:07:50 CTRL-C no Prompt - 31/08/2009 23:21:28 Desabilitando a geração do Thumbs.db - 13/05/2010 12:29:12
Últimos Artigos desta categoria Alterando a porta padrão do TS (3389) - 12/05/2010 10:07:50 Wake On LAN (WOL) - Ligue computadores remotamente - 22/02/2008 14:04:26 Navegação mais rapida - 08/09/2004 18:59:15
280 pessoa(s) on-line neste site.